Introduction
Water is a vital natural resource, and maintaining its quality is essential for human health, agriculture, and aquatic life. A Water Quality Monitoring System uses sensors and IoT technology to continuously monitor water parameters such as pH, turbidity, temperature, and water level, and sends the data to a cloud platform for real-time analysis.
This system helps detect water pollution early and ensures safe water usage.
Objective of the Project
- To monitor water quality parameters in real time
- To detect water contamination
- To display and store data on the cloud
- To ensure safe drinking and industrial water usage
Parameters Monitored
- pH Level – Acidity or alkalinity of water
- Turbidity – Water clarity
- Temperature – Water temperature
- Water Level – Quantity of water
Working Principle
- Sensors continuously sense water parameters
- Data is sent to a microcontroller (ESP32 / Arduino)
- Values are displayed on LCD / Serial Monitor
- Data is uploaded to a cloud platform using Wi-Fi
- Alerts can be generated if values cross safe limits
Components Required
- ESP32 / Arduino Uno
- pH Sensor
- Turbidity Sensor
- DS18B20 Temperature Sensor
- Water Level Sensor
- LCD / OLED Display
- Wi-Fi Module (ESP8266 if using Arduino)
- Jumper Wires
- Power Supply
Block Diagram
Water Sensors
(pH, Turbidity, Temp)
↓
ESP32 / Arduino
↓
LCD Display + Serial
↓
Wi-Fi Module
↓
Cloud Platform
Circuit Connections (ESP32 Example)
Sensor Connections
pH Sensor → GPIO34 (Analog)
Turbidity Sensor→ GPIO35 (Analog)
Temperature → GPIO4
Water Level → GPIO32 (Analog)
LCD SDA → GPIO21
LCD SCL → GPIO22
Arduino / ESP32 Code
#include <WiFi.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include "ThingSpeak.h"
#define PH_PIN 34
#define TURBIDITY_PIN 35
#define LEVEL_PIN 32
#define ONE_WIRE_BUS 4
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
const char* ssid = "Your_WiFi";
const char* password = "Your_Password";
WiFiClient client;
unsigned long channelID = 123456;
const char* writeAPIKey = "YOUR_API_KEY";
void setup() {
Serial.begin(9600);
sensors.begin();
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
}
ThingSpeak.begin(client);
}
void loop() {
int phValue = analogRead(PH_PIN);
int turbidity = analogRead(TURBIDITY_PIN);
int waterLevel = analogRead(LEVEL_PIN);
sensors.requestTemperatures();
float temperature = sensors.getTempCByIndex(0);
Serial.println("pH: " + String(phValue));
Serial.println("Turbidity: " + String(turbidity));
Serial.println("Water Level: " + String(waterLevel));
Serial.println("Temperature: " + String(temperature));
ThingSpeak.setField(1, phValue);
ThingSpeak.setField(2, turbidity);
ThingSpeak.setField(3, temperature);
ThingSpeak.setField(4, waterLevel);
ThingSpeak.writeFields(channelID, writeAPIKey);
delay(15000);
}
Code Explanation
- Sensors collect water quality data
- ESP32 reads analog and digital values
- Data is sent to ThingSpeak cloud
- Continuous monitoring every 15 seconds
Advantages
- Real-time water quality monitoring
- Early detection of pollution
- Low maintenance system
- Cloud-based data access
Applications
- Drinking water monitoring
- Industrial water quality control
- River and lake monitoring
- Smart agriculture and irrigation
Future Enhancements
- AI-based water quality prediction
- Mobile app alerts
- Automatic water purification control
- GPS-based location tracking
Conclusion
The Water Quality Monitoring System is an effective IoT-based solution to ensure safe and clean water. By continuously monitoring critical parameters and storing data on the cloud, it helps authorities and users make informed decisions for water safety.
