Wednesday, 27 May 2026

AI Smart Irrigation System with Weather Prediction and Soil Analysis

AI Smart Irrigation System with Weather Prediction and Soil Analysis AI-Powered ESP32 + Agentic IoT + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard
AI Smart Irrigation System with Weather Prediction and Soil Analysis AI-Powered ESP32 + Agentic IoT + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard 1. Project Overview This project is an intelligent IoT-based smart irrigation system using an ESP32 microcontroller integrated with: Soil moisture sensing Weather prediction logic AI-based irrigation decisions n8n automation workflows Telegram alerts + voice notifications Google Sheets logging ThingSpeak cloud dashboard Agentic AI automation behavior The system automatically: Monitors soil moisture Predicts irrigation need Controls water pump Sends voice/text alerts Logs sensor data to cloud Learns water usage patterns Reduces water wastage 2. System Features Core Features Real-time soil moisture monitoring Automatic irrigation pump control Temperature & humidity monitoring Rain/weather prediction support AI-based irrigation scheduling Remote cloud monitoring AI + Automation Features Agentic AI irrigation decisions Predictive water consumption analysis Telegram voice notifications Smart alerts using n8n workflows Cloud analytics dashboard Historical data storage 3. Hardware Components List Component Quantity ESP32 Dev Board 1 Capacitive Soil Moisture Sensor 1 DHT11/DHT22 Sensor 1 Relay Module 5V 1 Mini Water Pump 1 Breadboard 1 Jumper Wires Several 5V Power Supply 1 ThingSpeak Account 1 Telegram Bot 1 Google Account 1 n8n Cloud/Self-hosted 1 4. Working Principle The system continuously reads: Soil moisture Temperature Humidity The ESP32: Sends data to ThingSpeak Sends webhook data to n8n AI logic decides irrigation status Relay activates water pump Notifications sent to Telegram Data logged to Google Sheets 5. System Architecture [Soil Sensor] ----\ [DHT Sensor] ------> ESP32 ---> WiFi ---> n8n Workflow | +--> ThingSpeak Dashboard | +--> Google Sheets | +--> Telegram Bot | +--> AI Decision Engine 6. Circuit Schematic Diagram SOIL SENSOR VCC -> 3.3V GND -> GND AOUT -> GPIO34 DHT11 VCC -> 3.3V GND -> GND DATA -> GPIO4 RELAY MODULE VCC -> 5V GND -> GND IN -> GPIO26 WATER PUMP Connected through Relay 7. Flowchart START | Read Sensors | Check Moisture Level | Is Soil Dry? / \ YES NO | | Turn ON Pump | | Send Alert | | Upload Data | | Log to Sheets | | Repeat Loop 8. ESP32 Source Code (Arduino IDE) #include #include #include "DHT.h" #define DHTPIN 4 #define DHTTYPE DHT11 #define SOIL_PIN 34 #define RELAY_PIN 26 const char* ssid = "YOUR_WIFI_NAME"; const char* password = "YOUR_WIFI_PASSWORD"; String thingspeakApiKey = "YOUR_THINGSPEAK_API_KEY"; DHT dht(DHTPIN, DHTTYPE); void setup() { Serial.begin(115200); pinMode(RELAY_PIN, OUTPUT); digitalWrite(RELAY_PIN, HIGH); dht.begin(); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(1000); Serial.println("Connecting..."); } Serial.println("WiFi Connected"); } void loop() { int soilValue = analogRead(SOIL_PIN); float temp = dht.readTemperature(); float hum = dht.readHumidity(); Serial.print("Soil: "); Serial.println(soilValue); bool soilDry = soilValue > 2500; if (soilDry) { digitalWrite(RELAY_PIN, LOW); } else { digitalWrite(RELAY_PIN, HIGH); } if(WiFi.status()== WL_CONNECTED){ HTTPClient http; String url = "http://api.thingspeak.com/update?api_key=" + thingspeakApiKey + "&field1=" + String(soilValue) + "&field2=" + String(temp) + "&field3=" + String(hum); http.begin(url); int httpCode = http.GET(); Serial.println(httpCode); http.end(); } delay(15000); } 9. AI Irrigation Prediction Logic The AI logic estimates irrigation need based on: Soil moisture trend Temperature Humidity Time of day Weather forecast Basic AI Decision Formula I=w 1 ​ M+w 2 ​ T−w 3 ​ H+w 4 ​ W Where: I = Irrigation score M = Moisture deficit T = Temperature H = Humidity W = Weather prediction factor If: I>Threshold → Pump ON 10. n8n Workflow Logic Workflow Modules Webhook Trigger HTTP Request Node IF Condition Telegram Node Google Sheets Node Text-to-Speech API ThingSpeak Update 11. Sample n8n Workflow JSON { "nodes": [ { "name": "Webhook", "type": "n8n-nodes-base.webhook" }, { "name": "IF Soil Dry", "type": "n8n-nodes-base.if" }, { "name": "Telegram Alert", "type": "n8n-nodes-base.telegram" }, { "name": "Google Sheets", "type": "n8n-nodes-base.googleSheets" } ] } 12. Telegram Bot Setup Step 1 — Create Bot Open Telegram and search: Telegram Search: @BotFather Commands: /start /newbot Copy: BOT TOKEN Step 2 — Get Chat ID Send a message to your bot. Open: https://api.telegram.org/bot/getUpdates Copy: chat_id 13. Telegram Voice Notification Automation n8n can generate voice alerts using: Google Text-to-Speech ElevenLabs API gTTS Example Voice Message: Warning! Soil moisture is low. Irrigation pump activated automatically. 14. Google Sheets Integration Create a sheet: Time Soil Moisture Temperature Humidity Pump Status n8n appends rows automatically. Useful for: Analytics AI training Water usage reports 15. ThingSpeak Cloud Dashboard Setup Create account at: ThingSpeak Create Channel Fields Field Purpose Field1 Soil Moisture Field2 Temperature Field3 Humidity Field4 Pump Status Dashboard Widgets Gauge chart Line graph Real-time analytics Historical trends 16. Weather Prediction Integration Use: OpenWeather API Tomorrow.io API ESP32/n8n checks: Rain probability Temperature forecast Humidity forecast If rain expected: Skip irrigation 17. AI Power Consumption Prediction The system predicts pump power usage. Power Formula P=V×I×t Where: P = Power consumption V = Voltage I = Current t = Runtime AI estimates: Daily energy use Monthly water consumption Cost optimization 18. Advanced Agentic AI Features AI Agent Can: Decide irrigation timing Delay watering during rain Learn soil behavior Optimize water usage Predict dry conditions Generate smart reports 19. Future Enhancements Hardware Upgrades Solar-powered irrigation Multiple zone irrigation pH sensor integration Water flow sensor ESP32-CAM monitoring AI Enhancements Machine learning irrigation prediction LSTM moisture forecasting Crop-specific irrigation AI Edge AI using TinyML Cloud Enhancements Mobile app dashboard Firebase integration AWS IoT Core MQTT broker system 20. Deployment Guide Step-by-Step Deployment Hardware Assemble circuit Connect sensors Upload ESP32 code Cloud Configure ThingSpeak Setup Telegram bot Create Google Sheet Import n8n workflow Testing Dry soil manually Verify pump activation Verify Telegram alert Verify dashboard update 21. Expected Output Dashboard Shows Soil moisture % Temperature Humidity Pump status Water usage trends Telegram Alerts AI Irrigation Alert: Soil Dry Detected Pump Activated Temperature: 32°C Humidity: 45% 22. Applications Smart agriculture Greenhouse automation Precision farming Garden automation Water conservation systems 23. Conclusion This AI-powered smart irrigation system combines: ESP32 IoT Cloud computing AI prediction Automation workflows Telegram voice alerts Real-time dashboards The project demonstrates a modern Agentic IoT architecture suitable for: Smart farming Research projects Final-year engineering projects

No comments:

Post a Comment

AI Smart Traffic Signal Control Using Real-Time Vehicle Density Analysis

AI Smart Traffic Signal Control Using Real-Time Vehicle Density Analysis Agentic IoT System using ESP32 + AI + n8n + Telegram Voice Alerts +...