Arduino interfacing with Turbidity sensor
In this article we will learn how to interface arduino with Turbidity sensor.
In the last post we will learn how to interface arduino with I2C & LCD in proteus. You can visit our website,
I hope you appreciate my work, let’s discuss about today’s project.
What is turbidity sensor?
Turbidity sensors measure the amount of light that is scattered by the suspended solids in water. As the amount of total suspended solids in water increases, the water’s turbidity level (and cloudiness or haziness) increases.
Components of this project are listed below.
- Arduino nano
- Turbidity sensor module
- LCD 16×2
- 9V battery
- Push button
- Connecting wires
Diagram of this project is below:
Construction of Arduino interfacing with Turbidity sensor:
- Connect +ve point of the turbidity sensor module with 5V point of arduino nano
- Connect GND point of turbidity sensor module with GND point of arduino nano
- Connect signal point of turbidity sensor module with A3 point of arduino nano
- Connect the D2 point of arduino with the DB7 point of LCD
- Connect the D3 point of arduino with the DB6 point of LCD
- Connect the D4 point of arduino with the DB5 point of LCD
- Connect the D5 point of arduino with the DB4 point of LCD
- Connect the D6 point of arduino with the E point of LCD
- Connect the D7 point of arduino with the VDD point of LCD
- Connect the (K-, DB3, RW, VSS) points with each other through the GND point of arduino
- Connect VO point of LCD with 5V point of arduino nano
- Connect the 1 terminal of push button to the Vin point of arduino nano
- Connect the other terminal of push button with the +ve terminal of 5V battery
- Connect the –ve terminal of 5V battery with the GND point of arduino nano
Working of Arduino interfacing with Turbidity sensor:
Arduino can be used to interface with a turbidity sensor to measure the level of turbidity or cloudiness in a liquid, typically water. Turbidity sensors work by measuring the scattering and absorption of light as it passes through the liquid.
Applications of Arduino interfacing with Turbidity sensor:
- Water Quality Monitoring
- Wastewater Treatment
- Aquaculture Management
- Swimming Pool Water Quality
- Sediment Monitoring
Advantages of Arduino interfacing with Turbidity sensor:
- Cost-effective
- Versatility
- Open-source software
- Easy to learn and program
Program of this project is below:
#include <Wire.h>
#include <LiquidCrystal_I2C.h> //https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library
LiquidCrystal_I2C lcd(0x27, 16, 2);
int sensorPin = A3;
float volt;
float ntu;
void setup()
{
Serial.begin(9600);
// lcd.begin();
// lcd.backlight();
Serial.print(“hi=”);
}
void loop()
{
while(1){
int sensorValue = analogRead(A0);
float voltage = sensorValue * (5.0 / 1024.0);
Serial.println (“Sensor Output (V):”);
Serial.println (voltage);
Serial.println();
delay(1000);
}
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”);
Serial.print(“volt=”);
Serial.println(volt);
Serial.print(“NTU=”);
Serial.println(ntu);
// 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;
}