DIY Turbidity Meter using Analog Turbidity Sensor & Arduino

Overview: Turbidity Sensor & Arduino

In this project, we learn to make a DIY Turbidity Meter by interfacing DfRobot Turbidity Sensor with Arduino. Turbidity is the measure of relative clarity of a liquid. It is an optical characteristic of water and is a measurement of the amount of light that is scattered by material in the water when a light is shined through the water sample.

Arduino Turbidity Sensor is applied in projects involving the monitoring of water turbidity in rivers, streams, lakes, water bodies, catchment and research sites, laboratories, tanks with liquids, and so on. Thus by interfacing this sensor with Arduino, we can make a Water Quality Monitoring System device. The water quality measurement also includes some other sensors like Ph Sensor for measuring the Ph value of Liquid, also the TDS Sensor for measuring total dissolved solute in water & DO Sensor to measure dissolved oxygen in water.

We have already discussed Ph Sensor and TDS Sensor earlier. In this entire article, we will cover the basics of Turbidity Sensor and its practical demonstration in measuring Water Turbidity for Water Quality Monitoring. The Turbidity value is measured in terms of NTU which is called Nephelometric Turbidity Units. We will display the Arduino Turbidity Sensor value in the 16X2 LCD Display.

Bill of Materials

The following are the components required for making this project. All the components can be easily purchased from Amazon. The component purchase link is given as well.

S.N.Components NameQuantityPurchase Links

1Arduino UNO Board1Amazon | AliExpress

216×2 I2C LCD Display1Amazon | AliExpress

3Turbidity Sensor1Amazon | AliExpress

4Connecting Wires10Amazon | AliExpress

5Breadboard1Amazon | AliExpress

Turbidity of Water

What Is Turbidity?

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

Turbidity is caused by particles suspended or dissolved in water that scatter light making the water appear cloudy or murky. Particulate matter can include sediment, especially clay and silt, fine organic and inorganic matter, soluble colored organic compounds, algae, and other microscopic organisms.

Impact of Turbidity

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

Turbidity Sources

Sediment often tops the list of substances or pollutants causing turbidity. Natural sources can include erosion from upland, riparian, stream bank, and stream channel areas. Algae that grow with nourishment from nutrients entering the stream through leaf decomposition or other naturally occurring decomposition processes can also be a source of turbidity.

Stream channel movement can also release sediment. Organic matter from sewage discharges, especially during treatment plant bypasses, can contribute to turbidity. Human activities that disturb the land, such as construction, mining, and agriculture, can lead to high sediment levels entering water bodies during rainstorms due to stormwater runoff.

Measuring Turbidity

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

The unit of measurement is called a Nephelometric Turbidity Unit (NTU), which comes in several variations. 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

DfRobot Turbidity SensorDfRobot Turbidity Sensor

The gravity Arduino Turbidity sensor from DfRobot detects water quality by measuring the levels of turbidity. It uses light to detect suspended particles in water by measuring the light transmittance and scattering rate, which changes with the amount of total suspended solids (TSS) in water. As the TTS increases, the liquid turbidity level increases.

This liquid sensor provides analog and digital signal output modes. The threshold is adjustable when in digital signal mode. You can select the mode according to your Microcontroller Applications.

Working of a Turbidity Sensor

Working of Turbidity SensorWorking of Turbidity Sensor

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

Sensor Specification

1. Operating Voltage: 5V DC
2. Operating Current: 40mA (MAX)
3. Response Time: <500ms
4. Insulation Resistance: 100M (Min)
5. Output Method: Analog
6. Analog output: 0-4.5V
7. Digital Output: High/Low-level signal (you can adjust the threshold value by adjusting the potentiometer)

Sensor Construction & Circuit

The front-end sensor is an optical device comprising an LED (light sender) and a phototransistor (light receiver). The schematic of the Turbidity Sensor’s inside board is given below. It has a three-wire interface: VCC (+5 V), GND (0 V) & OUT/SIGNAL.

The Turbidity sensor has a signal connector Board as well. The signal connector board is directly connected to the above circuit.

The LMV358 IC-based module provides a three-pin interface to connect with Arduino, and there is also an analog/digital selector switch on the module to flip between analog and digital output mode.

Relationship Between Turbidity and Sensor Voltage

From the DfRobot Article, i got this graph with an equation that relates the voltage from the sensor to turbidity.

From this graph I concluded, while coding for your microcontroller-based project that the equation included in the relationship graph is only applicable if the sensor gives out 4.2 V roughly at zero turbidity (clear water), and it’s only true within the range of 2.5 V to 4.2 V (3,000 to 0 turbidity).

Thus if you are not getting the correct value, calibration is required. This can be done by rotating the small potentiometer inside the turbidity sensor.

Interfacing Turbidity Sensor with Arduino

Now let’s make a simple Turbidity Meter using Arduino. You can do this by simply connecting the Turbidity Sensor with Arduino Board.

Interfacing Turbidity Sensor ArduinoInterfacing Turbidity Sensor Arduino

Connect the VCC of the Turbidity Sensor with Arduino 5V, GND to GND & Analog Output to Arduino A0 pin as shown in the image above.

Basic Turbidity Sensor Arduino Interfacing Code

Here is a basic code for Interfacing Turbidity Sensor with Arduino. This code will read the analog value from the sensor and display it on the Serial Monitor.

1

2

3

4

5

6

7

8

9

10

11

12

13

void

setup

(

)

{

  

Serial

.

begin

(

9600

)

;

 

}

void

loop

(

)

{

  

int

sensorValue

=

analogRead

(

A0

)

;

  

float

voltage

=

sensorValue *

(

5.0

/

1024.0

)

;

 

  

Serial

.

println

(

“Sensor Output (V):”

)

;

  

Serial

.

println

(

voltage

)

;

  

Serial

.

println

(

)

;

  

delay

(

1000

)

;

}

Arduino Turbidity Meter with LCD Display

Now let us add an extra 16×2 I2C LCD Display to display the Turbidity Value in LCD Screen. The connection diagram is given below.

Turbidity Meter Arduino LCDTurbidity Meter Arduino LCD

We can use the I2C LCD to reduce the number of wiring. Connect the SDA & SCL Pin of I2C LCD to Arduino A4 (SDA) & A5 (SCL) Pin.

Arduino Turbidity Meter Source Code Program

Now let us check the Turbidity sensor Arduino Project code. You need to add the I2C LCD Library to the Arduino IDE. Download the library from this link.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

#include <Wire.h>

#include <LiquidCrystal_I2C.h>    //https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library

LiquidCrystal_I2C

lcd

(

0x27

,

16

,

2

)

;

 

int

sensorPin

=

A0

;

float

volt

;

float

ntu

;

void

setup

(

)

{

  

Serial

.

begin

(

9600

)

;

  

lcd

.

begin

(

)

;

  

lcd

.

backlight

(

)

;

}

void

loop

(

)

{

    

    

volt

=

0

;

    

for

(

int

i

=

0

;

i

<

800

;

i

++

)

    

{

        

volt

+=

(

(

float

)

analogRead

(

sensorPin

)

/

1023

)

*

5

;

    

}

    

volt

=

volt

/

800

;

    

volt

=

round_to_dp

(

volt

,

2

)

;

    

if

(

volt

<

2.5

)

{

      

ntu

=

3000

;

    

}

else

{

      

ntu

=

1120.4

*

square

(

volt

)

+

5742.3

*

volt

4353.8

;

    

}

    

lcd

.

clear

(

)

;

    

lcd

.

setCursor

(

0

,

0

)

;

    

lcd

.

print

(

volt

)

;

    

lcd

.

print

(

” V”

)

;

    

lcd

.

setCursor

(

0

,

1

)

;

    

lcd

.

print

(

ntu

)

;

    

lcd

.

print

(

” NTU”

)

;

    

delay

(

10

)

;

}

float

round_to_dp

(

float

in_value

,

int

decimal_place

)

{

  

float

multiplier

=

powf

(

10.0f

,

decimal_place

)

;

  

in_value

=

roundf

(

in_value *

multiplier

)

/

multiplier

;

  

return

in_value

;

}

Code Explanation

1

2

3

#include <Wire.h>

#include <LiquidCrystal_I2C.h>  

LiquidCrystal_I2C

lcd

(

0x27

,

16

,

2

)

;

First, we declared the Library for 16×2 LCD Display which has I2C Pins with I2C address of 0x27.

1

2

3

4

5

6

volt

=

0

;

    

for

(

int

i

=

0

;

i

<

800

;

i

++

)

    

{

        

volt

+=

(

(

float

)

analogRead

(

sensorPin

)

/

1023

)

*

5

;

    

}

    

volt

=

volt

/

800

;

The output analog voltage from the sensor has huge variations and its too noisy to measure. Hence we took the 800 readings and then took the average value for reading.

1

ntu

=

1120.4

*

square

(

volt

)

+

5742.3

*

volt

4352.9

;

Using this formula we converted the analog voltage value to NTU.

1

2

3

4

if

(

volt

<

2.5

)

{

      

ntu

=

3000

;

    

}

If the analog voltage reading goes below 2.5 V, the NTU is set to 3000. Thus 3000 is the maximum NTU value of the project.

Results & Observations

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

For example in clean water, the voltage will remain 4.2V. If it’s not showing 4.2 then you need to adjust the calibration by rotating the Potentiometer in Sensor.

Turbidity Sensor dfrobot ArduinoTurbidity Sensor dfrobot Arduino

Thus, the final Arduino Turbidity Meter is ready now and can be used for Water Quality Monitoring.

Video Tutorial & Guide

DIY Turbidity Meter using Arduino & Analog Turbidity Sensor

DIY Turbidity Meter using Arduino &amp; Analog Turbidity Sensor