Arduino UNO Smart Water Quality Monitoring System Using pH and Turbidity Sensor | IoT Water Testing Project
Smart Water Quality
Monitoring System
Measure pH, turbidity, and TDS (Total Dissolved Solids) in real time using Arduino UNO. This advanced environmental monitoring project is ideal for drinking water testing, aquaculture, wastewater analysis, and IoT-based smart water management.
Components Required
How the Monitoring System Works
- pH < 7 → Acidic water
- pH = 7 → Neutral (pure water)
- pH > 7 → Alkaline water
- Drinking water: pH 6.5 – 8.5
- Measures in NTU (Nephelometric)
- Clear water: < 1 NTU
- Drinking limit: < 4 NTU (WHO)
- High NTU signals contamination
- Measures in ppm (mg/L)
- Excellent: < 300 ppm
- Acceptable: 300 – 600 ppm
- Poor quality: > 900 ppm
Circuit Connections
| Component | Pin/Terminal | Arduino Pin | Wire |
|---|---|---|---|
| TDS Sensor | VCC | 5V | Red |
| GND | GND | Black | |
| AOUT | A0 | Orange | |
| pH Sensor | VCC | 5V | Red |
| GND | GND | Black | |
| AOUT | A1 | Yellow | |
| Turbidity Sensor | VCC | 5V | Red |
| GND | GND | Black | |
| AOUT | A2 | Green | |
| 16×2 LCD (4-bit) | VCC / VSS | 5V / GND | / |
| RS / E / R/W | D12 / D11 / GND | Blue | |
| D4–D7 | D10 / D9 / D8 / D7 | Purple |
All three sensor modules output a 0–5V analog signal proportional to their respective measurements. The Arduino's built-in 10-bit ADC converts these to values ranging from 0–1023.
diagram.json
Paste this into Wokwi's diagram.json tab. Three potentiometers simulate the sensor analog outputs — turn each to change readings.
{
"version": 1,
"author": "Arduino Water Quality Monitor",
"editor": "wokwi",
"parts": [
{
"type": "wokwi-arduino-uno", "id": "uno",
"top": 0, "left": 0, "attrs": {}
},
{
"type": "wokwi-potentiometer", "id": "tds_pot",
"top": -120, "left": -200,
"attrs": { "label": "TDS Sensor (A0)" }
},
{
"type": "wokwi-potentiometer", "id": "ph_pot",
"top": -120, "left": 0,
"attrs": { "label": "pH Sensor (A1)" }
},
{
"type": "wokwi-potentiometer", "id": "turb_pot",
"top": -120, "left": 200,
"attrs": { "label": "Turbidity (A2)" }
},
{
"type": "wokwi-lcd1602", "id": "lcd1",
"top": 200, "left": 200, "attrs": {}
}
],
"connections": [
// TDS sensor (potentiometer) → A0
[ "tds_pot:VCC", "uno:5V", "red", [ "v0" ] ],
[ "tds_pot:GND", "uno:GND.1", "black", [ "v0" ] ],
[ "tds_pot:SIG", "uno:A0", "orange", [ "v0" ] ],
// pH sensor (potentiometer) → A1
[ "ph_pot:VCC", "uno:5V", "red", [ "v0" ] ],
[ "ph_pot:GND", "uno:GND.1", "black", [ "v0" ] ],
[ "ph_pot:SIG", "uno:A1", "yellow", [ "v0" ] ],
// Turbidity sensor (potentiometer) → A2
[ "turb_pot:VCC", "uno:5V", "red", [ "v0" ] ],
[ "turb_pot:GND", "uno:GND.1", "black", [ "v0" ] ],
[ "turb_pot:SIG", "uno:A2", "green", [ "v0" ] ],
// LCD (4-bit mode)
[ "lcd1:VSS", "uno:GND.2", "black", [ "v0" ] ],
[ "lcd1:VDD", "uno:5V", "red", [ "v0" ] ],
[ "lcd1:V0", "uno:GND.2", "black", [ "v0" ] ],
[ "lcd1:RS", "uno:12", "blue", [ "v0" ] ],
[ "lcd1:RW", "uno:GND.2", "black", [ "v0" ] ],
[ "lcd1:E", "uno:11", "blue", [ "v0" ] ],
[ "lcd1:D4", "uno:10", "purple", [ "v0" ] ],
[ "lcd1:D5", "uno:9", "purple", [ "v0" ] ],
[ "lcd1:D6", "uno:8", "purple", [ "v0" ] ],
[ "lcd1:D7", "uno:7", "purple", [ "v0" ] ],
[ "lcd1:A", "uno:5V", "red", [ "v0" ] ],
[ "lcd1:K", "uno:GND.2", "black", [ "v0" ] ]
],
"dependencies": {}
}
Arduino Code
The code reads all three sensors every second and outputs formatted readings to the Serial Monitor. Extend it with the LCD library to show values on the 16×2 display.
/* * Arduino UNO Smart Water Quality Monitoring System * Sensors: TDS (A0), pH (A1), Turbidity (A2) * Output: Serial Monitor + 16x2 LCD * Use potentiometers in Wokwi to simulate sensor values */ // ── PIN DEFINITIONS ─────────────────────────────────────────── const int tdsPin = A0; // TDS sensor analog output const int phPin = A1; // pH sensor analog output const int turbidityPin = A2; // Turbidity sensor analog output // ── CALIBRATION CONSTANTS ───────────────────────────────────── // These map 0–1023 ADC range to real-world units. // Adjust these values for your specific sensor modules. const float TDS_FACTOR = 0.5; // ppm per ADC unit (approx) const float PH_OFFSET = 14.0; // pH 0–14 mapping offset const float TURB_FACTOR = 1.0; // NTU per ADC unit (approx) void setup() { Serial.begin(9600); pinMode(tdsPin, INPUT); pinMode(phPin, INPUT); pinMode(turbidityPin, INPUT); Serial.println("========================================"); Serial.println(" Smart Water Quality Monitoring System"); Serial.println(" Sensors: TDS | pH | Turbidity"); Serial.println("========================================"); Serial.println(); } void loop() { // Read raw ADC values (0–1023) int tdsRaw = analogRead(tdsPin); int phRaw = analogRead(phPin); int turbidityRaw = analogRead(turbidityPin); // Convert to real-world values float tdsValue = tdsRaw * TDS_FACTOR; float phValue = (phRaw / 1023.0) * PH_OFFSET; float turbidityValue = turbidityRaw * TURB_FACTOR; // Determine water quality labels String phStatus = (phValue < 6.5) ? "ACIDIC" : (phValue > 8.5) ? "ALKALINE" : "NORMAL"; String tdsStatus = (tdsValue < 300) ? "EXCELLENT" : (tdsValue < 600) ? "GOOD" : (tdsValue < 900) ? "ACCEPTABLE" : "POOR"; // Print formatted output to Serial Monitor Serial.println("──────────────────────────────────────"); Serial.print("TDS Value: "); Serial.print(tdsRaw); Serial.print(" raw → "); Serial.print(tdsValue, 1); Serial.print(" ppm ["); Serial.print(tdsStatus); Serial.println("]"); Serial.print("pH Value: "); Serial.print(phRaw); Serial.print(" raw → pH "); Serial.print(phValue, 2); Serial.print(" ["); Serial.print(phStatus); Serial.println("]"); Serial.print("Turbidity: "); Serial.print(turbidityRaw); Serial.print(" raw → "); Serial.print(turbidityValue, 1); Serial.println(" NTU"); Serial.println(); delay(1000); // Read every 1 second } /* ── SERIAL MONITOR OUTPUT EXAMPLE ────────────────────────────── ======================================== Smart Water Quality Monitoring System Sensors: TDS | pH | Turbidity ======================================== ────────────────────────────────────── TDS Value: 512 raw → 256.0 ppm [EXCELLENT] pH Value: 372 raw → pH 7.23 [NORMAL] Turbidity: 290 raw → 290.0 NTU ────────────────────────────────────── ... */
Key Features
Applications
Upgrade to IoT-Based Water Monitoring
This project can be expanded into a fully connected cloud-based monitoring solution suitable for smart cities, industrial automation, and agricultural management.
With ESP8266 or ESP32 integration, the system becomes a real-time cloud-based water quality monitoring solution deployable for smart cities and precision agriculture.
Comments
Post a Comment