Sunday, 31 May 2026

AI Smart Water Quality Monitoring and Prediction System

AI Smart Water Quality Monitoring and Prediction System AI-Powered ESP32 + Agentic IoT + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard
AI Smart Water Quality Monitoring and Prediction System AI-Powered ESP32 + Agentic IoT + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard 1. Project Overview The AI Smart Water Quality Monitoring and Prediction System continuously monitors water quality parameters using sensors connected to an ESP32. The collected data is uploaded to cloud platforms and analyzed using AI models to predict water contamination trends and power consumption. The system provides: ✅ Real-time Water Quality Monitoring ✅ Cloud Data Storage ✅ AI-Based Water Quality Prediction ✅ Automated n8n Workflow Processing ✅ Google Sheets Data Logging ✅ ThingSpeak Dashboard Visualization ✅ Telegram Notifications ✅ Telegram Voice Alerts ✅ AI Agent Analytics ✅ Remote Monitoring Through Web Dashboard 2. Objectives The system monitors: Water Temperature pH Level Turbidity TDS (Total Dissolved Solids) Water Quality Index (WQI) The AI Agent predicts: Water contamination risk Future water quality trend Sensor anomaly detection Power consumption forecast 3. System Architecture Sensors │ ▼ ESP32 Controller │ WiFi Internet │ ▼ ThingSpeak Cloud │ ├────────► Dashboard │ ▼ n8n Workflow │ ├────────► Google Sheets │ ├────────► AI Agent Analysis │ └────────► Telegram Bot │ ├── Text Alert └── Voice Alert 4. Required Components Component Quantity ESP32 Dev Board 1 pH Sensor Module 1 Turbidity Sensor 1 TDS Sensor 1 DS18B20 Temperature Sensor 1 Breadboard 1 Jumper Wires As required 4.7kΩ Resistor 1 Power Supply 1 WiFi Network 1 Computer/Laptop 1 5. Sensor Description pH Sensor Measures acidity or alkalinity. Range: 0 - 14 Ideal Drinking Water: 6.5 - 8.5 Turbidity Sensor Measures water clarity. Unit: NTU Lower value = Cleaner water TDS Sensor Measures dissolved solids. Unit: PPM Drinking Water: 50 - 300 PPM DS18B20 Measures water temperature. Range: -55°C to 125°C 6. Circuit Connections pH Sensor VCC → 5V GND → GND OUT → GPIO34 Turbidity Sensor VCC → 5V GND → GND OUT → GPIO35 TDS Sensor VCC → 5V GND → GND OUT → GPIO32 DS18B20 VCC → 3.3V GND → GND DATA → GPIO4 4.7kΩ between DATA and VCC 7. Circuit Schematic ESP32 GPIO34 ← pH Sensor GPIO35 ← Turbidity GPIO32 ← TDS Sensor GPIO4 ← DS18B20 WiFi │ ▼ ThingSpeak │ ▼ n8n ┌────────┼─────────┐ ▼ ▼ ▼ Google Telegram AI Agent Sheets Bot 8. Flowchart Start │ Initialize Sensors │ Connect WiFi │ Read Sensor Values │ Calculate Water Quality │ Send Data To ThingSpeak │ Trigger n8n Workflow │ Store In Google Sheet │ AI Agent Analysis │ Generate Alerts │ Telegram Notification │ Telegram Voice Alert │ Repeat Every Minute 9. ESP32 Source Code #include #include const char* ssid = "YOUR_WIFI"; const char* password = "YOUR_PASSWORD"; String apiKey = "YOUR_THINGSPEAK_API_KEY"; #define PH_PIN 34 #define TURB_PIN 35 #define TDS_PIN 32 void setup() { Serial.begin(115200); WiFi.begin(ssid,password); while(WiFi.status()!=WL_CONNECTED) { delay(500); } } void loop() { float phValue = analogRead(PH_PIN) * 14.0 / 4095.0; float turbidity = analogRead(TURB_PIN); float tds = analogRead(TDS_PIN); if(WiFi.status()==WL_CONNECTED) { HTTPClient http; String url = "http://api.thingspeak.com/update?api_key=" + apiKey + "&field1=" + String(phValue) + "&field2=" + String(turbidity) + "&field3=" + String(tds); http.begin(url); http.GET(); http.end(); } delay(60000); } 10. ThingSpeak Setup Step 1 Create account: ThingSpeak Step 2 Create New Channel Fields: Field1 = pH Field2 = Turbidity Field3 = TDS Field4 = Temperature Field5 = Water Quality Index Step 3 Copy Write API Key Step 4 Paste into ESP32 Code 11. Google Sheets Integration Create Sheet: Timestamp Temperature pH TDS Turbidity WQI Status Prediction 12. n8n Workflow Design Install: n8n Official Website Workflow: Webhook Trigger │ ▼ Read ThingSpeak Data │ ▼ AI Analysis │ ├── Google Sheets │ ├── Telegram Message │ │ └── Voice Alert 13. n8n Workflow JSON Structure { "nodes": [ { "name": "Webhook" }, { "name": "AI Agent" }, { "name": "Google Sheets" }, { "name": "Telegram" } ] } 14. Telegram Bot Setup Step 1 Open Telegram. Search: BotFather Step 2 /newbot Step 3 Create Bot Name. Step 4 Copy API Token. 15. Telegram Integration in n8n Add: Telegram Node Insert: Bot Token Chat ID Alert Message: ⚠ Water Quality Alert pH: {{$json.ph}} TDS: {{$json.tds}} Turbidity: {{$json.turbidity}} Risk Level: {{$json.risk}} 16. Voice Notification Automation n8n Process: AI Alert │ Generate Text │ Google TTS │ MP3 Voice │ Telegram Send Audio Voice Example: Warning. Water contamination level is increasing. Immediate inspection recommended. 17. AI Agent Analytics The AI Agent evaluates: Water Quality Index Excellent Good Moderate Poor Unsafe Contamination Detection Checks: High Turbidity High TDS Abnormal pH Sensor Health Monitoring Detects: Sensor Failure Missing Data Noise Data 18. AI Water Quality Prediction Logic Example Rule Engine: IF pH < 6.5 AND Turbidity > 500 THEN Risk = HIGH Prediction Model Inputs: Temperature pH TDS Turbidity Historical Data Outputs: Water Quality Score Future Risk Alert Probability Machine Learning Options: Linear Regression Random Forest XGBoost LSTM Time Series 19. AI Power Consumption Prediction Inputs: ESP32 Runtime WiFi Usage Sensor Operating Time Cloud Upload Frequency Formula: Power = Voltage × Current P=VI Example: Voltage = 5V Current = 0.18A Power = 0.9 Watts AI predicts: Daily Energy Usage Monthly Energy Usage Battery Life 20. Dashboard Features ThingSpeak Dashboard Displays: Live pH Graph TDS Graph Turbidity Graph Temperature Graph Water Quality Trend Prediction Trend Alert Status 21. Future Enhancements AI Enhancements Deep Learning Prediction Auto Calibration Edge AI on ESP32 TinyML Deployment Cloud Enhancements Multi-location Monitoring Mobile App Firebase Integration AWS IoT Integration Industrial Enhancements Water Treatment Plant Monitoring Smart City Water Management River Pollution Detection Industrial Wastewater Monitoring 22. Deployment Guide Small Scale Schools Colleges Homes Laboratories Medium Scale Apartment Complexes Water Tanks Hospitals Large Scale Municipal Water Systems Smart Cities Industrial Plants Final Outcome Complete AI-Powered Water Quality Monitoring Platform ✅ ESP32 IoT Monitoring ✅ Real-Time Water Quality Sensing ✅ AI Agent Analytics ✅ n8n Workflow Automation ✅ Google Sheets Database ✅ Telegram Text Alerts ✅ Telegram Voice Alerts ✅ ThingSpeak Cloud Dashboard ✅ Water Quality Prediction ✅ Power Consumption Prediction ✅ Cloud-Based Monitoring ✅ Scalable Smart Water Management Solution This project is suitable for final-year engineering projects, IoT research, smart city applications, environmental monitoring systems, and Industry 4.0 deployments.

No comments:

Post a Comment

AI-Based Real-Time Air Pollution Monitoring and Prediction

AI-Based Real-Time Air Pollution Monitoring and Prediction System ESP32 + AI Agent + IoT Cloud + n8n Automation + Telegram Voice Alerts + Go...