Arduino projects

DIY turbidity meter using sensor and Arduino

DIY turbidity meter using sensor and Arduino

In this tutorial, we will learn how to build a DIY turbidity meter by using a DfRobot turbidity sensor connected with an Arduino. Turbidity is a measure of the relative transparency of a liquid. It is an optical property of water and is a measure of the amount of light that is scattered by matter in the water when it passes through a sample of water.

Arduino Turbidity Sensor is used in projects that involve monitoring the turbidity of water in rivers, streams, lakes, water bodies, catchment areas and research sites, laboratories, liquid tanks, etc. So, by interfacing this sensor with Arduino, we can make a water quality monitoring system device. Water quality measurement also includes some other sensors such as pH sensor for measuring the pH value of liquid , TDS sensor for measuring the total dissolved solutes in water and DO sensor for measuring dissolved oxygen in water .

In this article, we will cover the basics of turbidity sensor and its practical example of measuring water turbidity in water quality monitoring. Turbidity values ​​are measured in NTU, known as Nephelometric Turbidity Units. We will display the Arduino turbidity sensor values ​​on an LCD display.

Required Components

● Arduino UNO development board

● 1602 LCD display

● DfRobot turbidity sensor

● Connect the jumper

● Breadboard

Water turbidity

What is turbidity?

Turbidity is the cloudiness or haziness of a fluid caused by large numbers of individual particles that are not normally visible to the naked eye, similar to smoke in the air. The measurement of turbidity is a key test for water quality.

DIY turbidity meter using sensor and Arduino

 

Turbidity is caused by particles suspended or dissolved in the water, which scatter light and make the water appear cloudy. Particulate matter can include sediment, especially clay and silt, fine organic and inorganic materials, soluble colored organic compounds, algae and other microorganisms.

Effect of turbidity

High turbidity can significantly reduce the aesthetic appeal of lakes and streams. It can increase water treatment costs for drinking water and food processing. It can harm fish and other aquatic life by reducing food supplies, degrading spawning beds, and affecting gill function.

Turbidity Source

Sediment usually tops the list of materials or pollutants that cause turbidity. Natural sources may include erosion from uplands, stream banks, riparian areas, and stream channels. Nutrients that enter streams through leaf decomposition or other naturally occurring decomposition processes, and algae that grow in response to these nutrients, can also be a source of turbidity.

Movement in stream channels can also release sediment. Organic matter in sewage discharge, especially near treatment plants, can cause turbidity. Human activities that disturb the land, such as construction, mining, and agriculture, can cause large amounts of sediment to enter water bodies as stormwater runoff during heavy rains.

Measuring turbidity

Turbidity is measured in the laboratory or in the field using specialized optical equipment. Light is directed through the water sample and the amount of light that is scattered is measured.

The unit of measurement is called the Nephelometric Turbidity Unit (NTU). The greater the scattering of light, the higher the turbidity. Low turbidity values ​​indicate high water clarity; high values ​​indicate low water clarity.

DfRobot Turbidity Sensor

DIY turbidity meter using sensor and Arduino

 

The Gravity Arduino Turbidity Sensor from DfRobot detects water quality by measuring turbidity values. It detects suspended particles in water by measuring light transmittance and scattering, which vary with the amount of total suspended solids (TSS) in the water. As TTS increases, the turbidity level of the liquid increases.

This sensor provides both analog and digital signal output modes. In digital signal mode, the threshold is adjustable. You can select the mode according to your microcontroller application.

Working Principle of Turbidity Sensor

DIY turbidity meter using sensor and Arduino

 

The sensor works on the principle that when light is passed through a water sample, the amount of light that is transmitted through the water sample depends on the amount of soil in the water. As the amount of soil increases, the amount of transmitted light decreases. The turbidity sensor measures the amount of transmitted light to determine the turbidity of the water.

Main specifications of the sensor

1. Working voltage: 5V DC

2. Working current: 40mA (MAX)

3. Response time: <500ms

4. Insulation resistance: 100M (Min)

5. Output mode: analog

6. Analog output: 0-4.5V

7. Digital output: high/low level signal (threshold can be adjusted by adjusting the potentiometer)

Sensor structure and circuit

DIY turbidity meter using sensor and Arduino

 

The front-end sensor is an optical device that includes an LED (light transmitter) and a phototransistor (light receiver). The schematic diagram of the turbidity sensor board is shown below. It has a three-wire interface: VCC (+5 V), GND (0 V) & OUT/SIGNAL.

DIY turbidity meter using sensor and Arduino

 

The turbidity sensor also has a signal connection board. The signal connection board connects directly to the above circuit.

The module is based on LMV358 and provides a three-pin interface for connecting to Arduino. There is also an analog/digital selection switch on the module to switch between analog and digital output modes.

DIY turbidity meter using sensor and Arduino

 

Relationship between turbidity and sensor voltage

From this DfRobot article , I got this graph which contains an equation relating the sensor voltage to turbidity.

DIY turbidity meter using sensor and Arduino

 

As you can see from this diagram, when coding a microcontroller based project, the equations contained in the diagram only apply if the sensor gives approximately 4.2V at zero turbidity (clear water), and are only correct in the range of 2.5V to 4.2V (3,000 to 0 turbidity).

So if you are not getting the correct value you will need to calibrate it. This can be done by turning the potentiometer inside the turbidity sensor.

Interfacing Turbidity Sensor with Arduino

Now let us make a simple Turbidity Meter using Arduino. You can make it by directly interfacing the Turbidity Sensor with the Arduino board.

DIY turbidity meter using sensor and Arduino

 

As shown in the figure above, connect the VCC and GND of the turbidity sensor to the 5V and GND pins of the Arduino development board respectively, and the analog output to the A0 pin of the Arduino.

Following is the basic code for interfacing the turbidity sensor with Arduino. This code will read the analog value from the sensor and display it on the serial monitor.

  1. void setup() {
  2.   Serial.begin(9600);
  3. }
  4. void loop() {
  5.   int sensorValue = analogRead(A0);
  6.   float voltage = sensorValue * (5.0 / 1024.0);
  7.   Serial.println (“Sensor Output (V):”);
  8.   Serial.println(voltage);
  9.   Serial.println();
  10.   delay(1000);
  11. }

Copy code

Arduino Turbidimeter using LCD Display

Now let us add a 1602 LCD display to show the turbidity value. The connection diagram is given below.

DIY turbidity meter using sensor and Arduino

 

We can use an I2C interface LCD to reduce the number of wiring. Connect the SDA and SCL pins of the I2C LCD display to the A4 (SDA) and A5 (SCL) pins of the Arduino development board respectively.

Code for Arduino Turbidimeter

Now let us write the Arduino code for the turbidity meter. You need to add the I2C LCD library to the Arduino IDE. Download the library from this link: I2C LCD Library . Complete Code:  Arduino Turbidity Meter.rar (595 Bytes, Downloads: 34)

Code Description

  1. #include <Wire.h>
  2. #include <LiquidCrystal_I2C.h>  
  3. LiquidCrystal_I2C lcd(0x27, 16, 2);

Copy code

First, we declare the library for the 16×2 LCD display with an I2C address of 0x27.

  1. volt = 0;
  2.     for(int i=0; i<800; i++)
  3.     {
  4.         volt += ((float)analogRead(sensorPin)/1023)*5;
  5.     }
  6.     volt = volt/800;

Copy code

The output analog voltage of the sensor varies a lot and is too noisy to measure. Therefore, we take 800 readings and then average them for the reading.

  1. ntu = -1120.4*square(volt)+5742.3*volt-4352.9;

Copy code

Using this formula, we convert the analog voltage value into NTU.

  1. if(volt < 2.5)
  2. {
  3.       ntu = 3000;
  4.     }

Copy code

If the analog voltage reading is below 2.5 V, the NTU is set to 3000. Because 3000 is the maximum NTU value for the project.

Observe the running results

To check the working of the project, you can immerse the sensor in different types of water sources. You can mix mud or clay and check the water turbidity NTU.

For example in clear water the voltage will remain at 4.2 V. If it does not show 4.2 then you need to adjust the calibration by turning the potentiometer in the sensor.

DIY turbidity meter using sensor and Arduino

 

The above is how to use the DfRobot turbidity sensor and Arduino development board to make a turbidity meter, which can be used for water quality monitoring. If you have any questions, please feel free to reply below this post.

Check Also
Close
Back to top button