Wednesday, 27 May 2026

AI-Based Animal Intrusion Detection for Agriculture Fields

AI-Based Animal Intrusion Detection for Agriculture Fields AI-Powered Agentic IoT System using ESP32 + n8n + Telegram Voice Alerts + Google Sheets + ThingSpeak
1. Project Overview This project is an intelligent agriculture security system that detects animal intrusion in farm fields using AI-enabled IoT automation. The system uses an ESP32 microcontroller connected to motion and distance sensors. When an animal enters the protected area: ESP32 captures intrusion data Sends alerts to cloud services Triggers AI-based automation using n8n Sends Telegram notifications with voice alerts Stores logs in Google Sheets Displays live analytics on ThingSpeak dashboard Predicts future power consumption using AI logic This system helps farmers: Prevent crop damage Monitor fields remotely Receive instant warnings Analyze intrusion patterns Reduce manual surveillance 2. System Architecture ┌────────────────────┐ │ Animal Movement │ └─────────┬──────────┘ │ ┌─────────▼──────────┐ │ PIR / Ultrasonic │ │ Sensors │ └─────────┬──────────┘ │ ┌─────────▼──────────┐ │ ESP32 │ │ WiFi + AI Logic │ └─────────┬──────────┘ │ HTTP/MQTT ┌─────────────────┼─────────────────┐ │ │ │ ▼ ▼ ▼ ┌────────────┐ ┌─────────────┐ ┌──────────────┐ │ ThingSpeak │ │ n8n Server │ │ Google Sheet │ └────────────┘ └──────┬──────┘ └──────────────┘ │ ┌──────────▼───────────┐ │ Telegram Bot Alerts │ │ Voice + Text Message │ └──────────────────────┘ 3. Features Core Features Animal intrusion detection Real-time Telegram alerts AI-based intrusion classification Voice warning notifications Cloud dashboard monitoring Google Sheets logging Automated workflows using n8n AI Features Power usage prediction Intrusion frequency analysis Smart alert prioritization Future threat prediction IoT Features WiFi connectivity Cloud synchronization Remote monitoring Edge-device automation 4. Required Components List Component Quantity Purpose ESP32 Dev Board 1 Main controller PIR Motion Sensor 1 Motion detection Ultrasonic Sensor HC-SR04 1 Distance sensing Buzzer 1 Local alarm LED Indicators 2 Status display Jumper Wires Several Connections Breadboard 1 Prototyping Power Supply 5V 1 System power WiFi Network 1 Internet connectivity Telegram Bot 1 Notifications ThingSpeak Account 1 Cloud dashboard Google Account 1 Sheets integration n8n Server 1 Automation workflows 5. Circuit Schematic Diagram ESP32 PIN CONNECTIONS PIR Sensor ----------- VCC -> 3.3V GND -> GND OUT -> GPIO 13 Ultrasonic Sensor HC-SR04 ------------------------- VCC -> 5V GND -> GND TRIG -> GPIO 12 ECHO -> GPIO 14 Buzzer ------- + -> GPIO 27 - -> GND LED --- + -> GPIO 26 - -> GND 6. Working Principle PIR sensor detects motion. Ultrasonic sensor measures object distance. ESP32 validates intrusion. Data uploaded to ThingSpeak. ESP32 triggers webhook to n8n. n8n: Sends Telegram text alert Generates voice notification Stores records in Google Sheets AI logic predicts power usage trends. Dashboard visualizes all activities. 7. Flowchart START │ Initialize ESP32 │ Connect WiFi │ Read PIR Sensor │ Motion Detected? ┌─No─────────────┐ │ │ │ Wait │ │ └────Yes─────────┘ │ Measure Distance │ Animal Detected? ┌─No─────────────┐ │ │ │ Continue │ │ └────Yes─────────┘ │ Activate Buzzer │ Send Data to ThingSpeak │ Trigger n8n Webhook │ Telegram Alert + Voice │ Store Data in Sheets │ Repeat 8. ESP32 Source Code (Arduino IDE) #include #include const char* ssid = "YOUR_WIFI_NAME"; const char* password = "YOUR_WIFI_PASSWORD"; String webhookURL = "YOUR_N8N_WEBHOOK_URL"; #define PIR_PIN 13 #define TRIG_PIN 12 #define ECHO_PIN 14 #define BUZZER 27 #define LED 26 long duration; float distance; void setup() { Serial.begin(115200); pinMode(PIR_PIN, INPUT); pinMode(TRIG_PIN, OUTPUT); pinMode(ECHO_PIN, INPUT); pinMode(BUZZER, OUTPUT); pinMode(LED, OUTPUT); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(1000); Serial.println("Connecting..."); } Serial.println("WiFi Connected"); } float getDistance() { digitalWrite(TRIG_PIN, LOW); delayMicroseconds(2); digitalWrite(TRIG_PIN, HIGH); delayMicroseconds(10); digitalWrite(TRIG_PIN, LOW); duration = pulseIn(ECHO_PIN, HIGH); distance = duration * 0.034 / 2; return distance; } void loop() { int motion = digitalRead(PIR_PIN); if (motion == HIGH) { distance = getDistance(); if (distance < 150) { digitalWrite(BUZZER, HIGH); digitalWrite(LED, HIGH); sendAlert(distance); delay(5000); digitalWrite(BUZZER, LOW); digitalWrite(LED, LOW); } } delay(1000); } void sendAlert(float dist) { if(WiFi.status()== WL_CONNECTED){ HTTPClient http; String url = webhookURL + "?distance=" + String(dist); http.begin(url); int httpCode = http.GET(); Serial.println(httpCode); http.end(); } } 9. n8n Workflow Logic Workflow Steps Webhook Trigger │ ▼ AI Decision Node │ ▼ Telegram Message Node │ ▼ Google Sheets Node │ ▼ ThingSpeak Update Node │ ▼ Text-to-Speech Node │ ▼ Telegram Voice Send 10. Sample n8n Workflow JSON { "nodes": [ { "name": "Webhook", "type": "n8n-nodes-base.webhook", "parameters": { "path": "animal-alert" } }, { "name": "Telegram Alert", "type": "n8n-nodes-base.telegram", "parameters": { "text": "Animal detected in field!" } } ] } 11. Telegram Bot Setup Step 1: Create Bot Open Telegram and search: Telegram Then search for: BotFather Commands: /newbot Provide: Bot Name Username Copy generated API token. Step 2: Get Chat ID Send message to your bot. Open: https://api.telegram.org/botYOUR_BOT_TOKEN/getUpdates Copy: chat.id 12. Google Sheets Integration Steps Create new Google Sheet Add columns: | Timestamp | Distance | Alert Type | Power Usage | In n8n: Add Google Sheets node Authenticate Google account Select spreadsheet Append rows automatically Recommended columns: Timestamp Animal Type Distance Battery Voltage Alert Status 13. ThingSpeak Cloud Dashboard Setup Create account on: ThingSpeak Create Channel Fields Field Purpose Field 1 Distance Field 2 Motion Field 3 Battery Field 4 Intrusion Count Dashboard Widgets Live intrusion graph Daily activity chart Battery monitor AI prediction chart 14. AI Power Consumption Prediction Logic Objective Predict battery drain and optimize power usage. Inputs Sensor active time Alert frequency WiFi transmission count Buzzer usage duration Simple Prediction Formula The estimated power model: P daily ​ =P idle ​ +n(P wifi ​ +P sensor ​ +P buzzer ​ ) Where: P daily ​ = total daily consumption n = number of intrusion events AI Enhancement Use: Moving average prediction Linear regression Intrusion trend analysis Future AI models: TinyML on ESP32 Edge AI classification Animal species prediction 15. Voice Notification Automation Workflow Intrusion Detected │ ▼ n8n Receives Webhook │ ▼ Text-to-Speech API │ ▼ Generate MP3 Voice │ ▼ Send Telegram Voice Message Example Voice Message Warning! Animal detected in agricultural field sector 3. 16. AI Agentic Automation Concept The system behaves like an AI agent: AI Agent Capability Function Observe Sensor monitoring Analyze Intrusion validation Decide Threat classification Act Send alerts Learn Analyze intrusion history 17. Future Enhancements AI Improvements YOLO animal detection camera TinyML animal classification AI-based crop damage prediction Hardware Enhancements Solar-powered system GSM backup connectivity LoRa communication Cloud Enhancements Mobile app dashboard Firebase integration AWS IoT integration Security Improvements Multi-factor authentication Encrypted communication Edge anomaly detection 18. Deployment Guide Farm Installation Tips Mount sensors 2–3 feet above ground Use waterproof enclosure Install solar charging Ensure stable WiFi coverage Power Optimization Deep sleep mode on ESP32 Send alerts only on confirmed detection Reduce WiFi transmission intervals 19. Advantages Low-cost smart agriculture solution Real-time remote monitoring AI-assisted automation Easy cloud integration Scalable architecture Energy efficient 20. Applications Agricultural farms Forest boundary monitoring Smart villages Wildlife intrusion prevention Crop protection systems 21. Conclusion This AI-powered Agentic IoT system combines: ESP32 AI automation Cloud dashboards Telegram voice alerts n8n workflows Google Sheets analytics to create a complete smart agriculture protection platform capable of intelligent monitoring, automation, and predictive analytics. The project is highly scalable and can evolve into: AI wildlife monitoring Smart farm automation Precision agriculture systems Edge AI surveillance platforms

AI Smart Wheelchair with Voice and Eye Control

AI Smart Wheelchair with Voice and Eye Control AI-Powered ESP32 + Agentic IoT + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Dashboard
AI Smart Wheelchair with Voice and Eye Control AI-Powered ESP32 + Agentic IoT + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Dashboard 1. Project Overview This project is an AI-enabled Smart Wheelchair designed for elderly and disabled individuals. The wheelchair can be controlled using: 👁️ Eye movement tracking 🎙️ Voice commands 📱 Mobile IoT dashboard 🤖 AI-based automation The system uses an ESP32 microcontroller integrated with: Sensors Motor drivers Cloud platforms AI analytics n8n workflow automation Telegram voice alert system The wheelchair also sends: Battery health alerts Emergency notifications Usage analytics Power consumption predictions 2. Key Features Smart Control Features Voice-controlled navigation Eye-controlled movement Obstacle detection Automatic braking AI-assisted movement prediction IoT Features Real-time monitoring Cloud dashboard Telegram alerts Google Sheets logging Remote tracking AI Features Battery prediction Usage pattern learning Intelligent alert generation Power optimization 3. System Architecture +----------------------+ | User Voice | +----------+-----------+ | v Voice Recognition | v +-------------+ +-------------+ +--------------+ | Eye Sensor | --> | ESP32 | --> | Motor Driver | +-------------+ +-------------+ +--------------+ | ---------------------------------------- | | | v v v ThingSpeak Google Sheets Telegram Bot | | | -------------------------------------- | v n8n AI Automation 4. Components List Component Quantity Purpose ESP32 Dev Board 1 Main controller L298N Motor Driver 1 Motor control DC Geared Motors 2 Wheelchair movement IR Eye Blink Sensor 1 Eye movement detection Ultrasonic Sensor HC-SR04 2 Obstacle detection Microphone Module 1 Voice command input Battery Pack 12V 1 Power supply Buck Converter 1 Voltage regulation Relay Module 1 Safety shutdown Buzzer 1 Alert system WiFi Router/Hotspot 1 Internet connectivity Jumper Wires Multiple Connections Wheelchair Chassis 1 Base frame 5. Circuit Schematic Diagram +----------------+ | ESP32 | | | | GPIO 18 -----> Motor IN1 | GPIO 19 -----> Motor IN2 | GPIO 21 -----> Motor IN3 | GPIO 22 -----> Motor IN4 | GPIO 5 <---- Eye Sensor | GPIO 13 <---- Echo | GPIO 12 ----> Trigger | GPIO 34 <---- Mic Module | GPIO 25 ----> Buzzer +----------------+ | v WiFi Connection | ------------------------ | | | v v v Telegram n8n ThingSpeak 6. Flowchart START | v Initialize ESP32 | v Connect to WiFi | v Read Sensors Data | ------------------- | | | v v v Voice Eye Obstacle Command Movement Detection | | | ---------- | | | v | Control Motors <--- | v Upload Data to Cloud | v Trigger n8n Workflow | v Send Telegram Alerts | v LOOP 7. ESP32 Source Code (Arduino IDE) #include #include const char* ssid = "YOUR_WIFI_NAME"; const char* password = "YOUR_WIFI_PASSWORD"; String apiKey = "THINGSPEAK_API_KEY"; #define IN1 18 #define IN2 19 #define IN3 21 #define IN4 22 #define trigPin 12 #define echoPin 13 #define eyeSensor 5 #define buzzer 25 long duration; int distance; void setup() { Serial.begin(115200); pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT); pinMode(IN3, OUTPUT); pinMode(IN4, OUTPUT); pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); pinMode(eyeSensor, INPUT); pinMode(buzzer, OUTPUT); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println("WiFi Connected"); } void loop() { // Ultrasonic Distance digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); distance = duration * 0.034 / 2; // Eye Sensor int eyeState = digitalRead(eyeSensor); if(distance < 20) { stopWheelchair(); digitalWrite(buzzer, HIGH); } else { digitalWrite(buzzer, LOW); if(eyeState == HIGH) { moveForward(); } else { stopWheelchair(); } } uploadThingSpeak(distance, eyeState); delay(3000); } void moveForward() { digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW); digitalWrite(IN3, HIGH); digitalWrite(IN4, LOW); } void stopWheelchair() { digitalWrite(IN1, LOW); digitalWrite(IN2, LOW); digitalWrite(IN3, LOW); digitalWrite(IN4, LOW); } void uploadThingSpeak(int distance, int eye) { if(WiFi.status()== WL_CONNECTED){ HTTPClient http; String url = "http://api.thingspeak.com/update?api_key=" + apiKey + "&field1=" + String(distance) + "&field2=" + String(eye); http.begin(url); int httpCode = http.GET(); Serial.println(httpCode); http.end(); } } 8. n8n Workflow Logic Workflow Functions Receive ESP32 webhook data Analyze sensor values Generate AI decisions Send Telegram alerts Store logs in Google Sheets Trigger voice notifications n8n Workflow Steps Webhook Trigger | v HTTP Request (ESP32 Data) | v IF Node (distance < 20?) | YES/NO | v Telegram Alert | v Google Sheets Logging | v AI Processing Node | v Voice Notification 9. Example n8n Workflow JSON { "nodes": [ { "name": "Webhook", "type": "n8n-nodes-base.webhook", "parameters": { "path": "wheelchair-data" } }, { "name": "Telegram", "type": "n8n-nodes-base.telegram", "parameters": { "chatId": "YOUR_CHAT_ID", "text": "Obstacle detected!" } } ] } 10. Telegram Bot Setup Step 1: Create Bot Open Telegram and search: Telegram Then message: @BotFather Commands: /newbot BotFather provides: Bot Token API access Step 2: Get Chat ID Send message to your bot. Open: https://api.telegram.org/bot/getUpdates Find: "chat":{"id":123456789} Step 3: Send Notifications Example API: https://api.telegram.org/bot/sendMessage?chat_id=&text=ObstacleDetected 11. Google Sheets Integration Create Sheet Columns Time Distance Eye State Battery Status n8n Google Sheets Node Connect Google account Select Spreadsheet Append Rows automatically Data stored: Sensor logs Alerts Battery prediction User activity 12. ThingSpeak Dashboard Setup Create Channel Use: ThingSpeak Create Fields: Distance Eye Sensor Battery Temperature Dashboard Widgets Live graph Gauge meter Alert chart Battery analytics 13. AI Power Consumption Prediction Logic Goal Predict battery drain and optimize wheelchair runtime. Inputs Motor usage time Obstacle frequency Distance traveled Battery voltage Speed AI Formula Battery Consumption: P=V×I Remaining Battery Estimate: Battery Remaining=Battery total ​ −Consumption Prediction Logic IF battery < 20% Send Alert Reduce Motor Speed Enable Power Saving 14. Voice Notification Automation Telegram Voice Alerts n8n converts text to speech: “Obstacle detected” “Battery low” “Emergency assistance required” Workflow ESP32 Event | v n8n Webhook | v AI Decision | v Text-to-Speech | v Telegram Voice Message 15. AI Agentic Features Intelligent Behaviors Learns user movement patterns Predicts battery usage Detects abnormal activity Sends autonomous alerts Example AI Actions Situation AI Response Low battery Reduce speed Obstacle nearby Stop wheelchair Emergency detected Notify caregiver Long inactivity Trigger wellness alert 16. Future Enhancements Advanced AI Features Face recognition Emotion detection Health monitoring Fall detection IoT Upgrades GPS tracking Mobile app Cloud AI dashboard Remote driving Hardware Upgrades Li-ion smart BMS Brushless motors Solar charging Autonomous navigation 17. Deployment Guide Hardware Assembly Mount motors Install ESP32 Connect sensors Attach battery Configure wiring Software Installation Arduino IDE Install: ESP32 board package WiFi library HTTPClient library Cloud Setup Configure ThingSpeak API Configure n8n workflow Setup Telegram bot Connect Google Sheets 18. Applications Disabled assistance Elderly mobility Smart hospitals Rehabilitation centers AI healthcare systems 19. Advantages Hands-free control Low-cost AI system Real-time monitoring Emergency automation Cloud analytics 20. Conclusion This project combines: ESP32 IoT AI automation Voice control Eye tracking Cloud analytics Agentic workflows to create a modern AI Smart Wheelchair System capable of improving mobility, safety, and independence for users with physical disabilities.

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 + Google Sheets + ThingSpeak
AI Smart Traffic Signal Control Using Real-Time Vehicle Density Analysis Agentic IoT System using ESP32 + AI + n8n + Telegram Voice Alerts + Google Sheets + ThingSpeak 1. Project Overview This project is an AI-powered smart traffic management system that dynamically controls traffic lights based on real-time vehicle density using an ESP32 microcontroller, IoT cloud services, and automation workflows. The system: Detects vehicle density using sensors/camera logic Uses AI logic to optimize signal timing Sends data to cloud dashboards Stores traffic logs in Google Sheets Generates Telegram alerts and voice notifications Uses n8n workflows for automation Predicts congestion and power consumption trends 2. Objectives Reduce traffic congestion Minimize waiting time Optimize signal timing automatically Enable remote monitoring Provide real-time traffic analytics Generate AI-based predictions Enable smart city integration 3. System Architecture Vehicle Sensors / Camera ↓ ESP32 ↓ WiFi / Internet Connection ↓ ┌────────────────────────────┐ │ Cloud Services │ │----------------------------│ │ ThingSpeak Dashboard │ │ Google Sheets Logging │ │ Telegram Alerts │ │ n8n Automation │ └────────────────────────────┘ ↓ AI Decision Engine ↓ Smart Traffic Signal Control 4. Hardware Components List Component Quantity Purpose ESP32 Dev Board 1 Main controller Ultrasonic Sensors HC-SR04 4 Vehicle density detection Traffic LEDs (Red/Yellow/Green) 12 Traffic lights Resistors 220Ω 12 LED protection Breadboard 1 Prototyping Jumper Wires Multiple Connections Buzzer 1 Alert indication 5V Power Supply 1 System power WiFi Router 1 Internet connectivity Optional Camera Module 1 AI vision enhancement 5. Working Principle Each road lane contains an ultrasonic sensor. The ESP32: Measures vehicle queue length Calculates density score Assigns green signal duration dynamically Uploads data to cloud Triggers alerts during congestion AI Logic High density → longer green signal Low density → shorter green signal Emergency override supported Predictive congestion analysis possible 6. Traffic Density Logic Example density ranges: Distance Measured Traffic Density > 80 cm Low 40–80 cm Medium < 40 cm High Signal timing: Density Green Time Low 10 sec Medium 20 sec High 35 sec 7. Circuit Schematic Diagram +------------------+ | ESP32 | | | HC-SR04_1 --> GPIO 4,5 HC-SR04_2 --> GPIO 18,19 HC-SR04_3 --> GPIO 21,22 HC-SR04_4 --> GPIO 23,25 RED LEDs --> GPIO 12,13,14,15 YELLOW LEDs --> GPIO 26,27,32,33 GREEN LEDs --> GPIO 2,16,17,18 BUZZER --> GPIO 5 WiFi --> Cloud Services +------------------+ 8. Flowchart START ↓ Initialize ESP32 ↓ Connect WiFi ↓ Read Sensor Data ↓ Calculate Vehicle Density ↓ AI Decision Engine ↓ Set Traffic Signal Timing ↓ Upload Data to ThingSpeak ↓ Store Data in Google Sheets ↓ Trigger Telegram Alerts ↓ Repeat Loop 9. ESP32 Source Code (Arduino IDE) #include #include const char* ssid = "YOUR_WIFI_NAME"; const char* password = "YOUR_WIFI_PASSWORD"; String apiKey = "THINGSPEAK_API_KEY"; #define RED1 12 #define YELLOW1 26 #define GREEN1 2 #define TRIG1 4 #define ECHO1 5 long duration; int distance; WiFiClient client; void setup() { Serial.begin(115200); pinMode(TRIG1, OUTPUT); pinMode(ECHO1, INPUT); pinMode(RED1, OUTPUT); pinMode(YELLOW1, OUTPUT); pinMode(GREEN1, OUTPUT); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(1000); Serial.println("Connecting..."); } Serial.println("WiFi Connected"); } int getDistance() { digitalWrite(TRIG1, LOW); delayMicroseconds(2); digitalWrite(TRIG1, HIGH); delayMicroseconds(10); digitalWrite(TRIG1, LOW); duration = pulseIn(ECHO1, HIGH); distance = duration * 0.034 / 2; return distance; } void loop() { int density = getDistance(); int greenTime = 10; if (density < 40) { greenTime = 35; } else if (density < 80) { greenTime = 20; } digitalWrite(GREEN1, HIGH); delay(greenTime * 1000); digitalWrite(GREEN1, LOW); digitalWrite(YELLOW1, HIGH); delay(3000); digitalWrite(YELLOW1, LOW); digitalWrite(RED1, HIGH); delay(5000); sendToThingSpeak(density, greenTime); } void sendToThingSpeak(int density, int greenTime) { if(WiFi.status()== WL_CONNECTED){ HTTPClient http; String url = "http://api.thingspeak.com/update?api_key=" + apiKey + "&field1=" + String(density) + "&field2=" + String(greenTime); http.begin(url); int httpCode = http.GET(); Serial.println(httpCode); http.end(); } } 10. ThingSpeak Cloud Dashboard Setup Using ThingSpeak Steps Create account Create new channel Add fields: Vehicle Density Green Signal Time Congestion Score Copy Write API Key Add API key into ESP32 code Dashboard features: Real-time graphs Traffic analytics Historical trends AI prediction visualization 11. Google Sheets Integration Using: Google Apps Script Webhook API n8n automation Data Stored Time Density Green Time Alert Google Apps Script function doPost(e) { var sheet = SpreadsheetApp.getActiveSheet(); var data = JSON.parse(e.postData.contents); sheet.appendRow([ new Date(), data.density, data.greenTime, data.alert ]); return ContentService .createTextOutput("Success"); } Deploy as: Web App Access: Anyone 12. Telegram Bot Setup Using Telegram BotFather Steps Open Telegram Search “BotFather” Create bot using: /newbot Copy bot token Get Chat ID Use HTTP API in n8n 13. Telegram Voice Notification Alerts Example alert: ⚠ Heavy Traffic Detected at Junction 2 Green Signal Extended to 35 Seconds Voice generation options: Google TTS ElevenLabs gTTS Python API 14. n8n Automation Workflow Using n8n Automation Platform Workflow Functions Receive ESP32 webhook data Analyze congestion Store records Trigger Telegram notifications Generate voice alerts Predict traffic trends n8n Workflow Structure Webhook Trigger ↓ Data Parser ↓ IF Density > Threshold ↓ ┌──────────────┬───────────────┐ ↓ ↓ Telegram Msg Google Sheets ↓ Voice Alert ↓ ThingSpeak Update 15. Sample n8n Workflow JSON { "nodes": [ { "name": "Webhook", "type": "n8n-nodes-base.webhook", "position": [250, 300] }, { "name": "IF Traffic High", "type": "n8n-nodes-base.if", "position": [500, 300] }, { "name": "Telegram Alert", "type": "n8n-nodes-base.telegram", "position": [750, 200] }, { "name": "Google Sheets", "type": "n8n-nodes-base.googleSheets", "position": [750, 400] } ] } 16. AI Power Consumption Prediction Logic The AI module predicts: Power usage Peak traffic hours Congestion patterns Energy optimization Simple Prediction Formula P=V×I Where: P = Power V = Voltage I = Current AI Prediction Parameters Parameter Usage Vehicle Count Congestion estimate Signal Duration Energy usage Peak Time Traffic prediction Historical Data ML training 17. AI Enhancement Possibilities Machine Learning Features Vehicle classification Emergency vehicle detection Accident detection Adaptive traffic prediction Smart rerouting Possible AI frameworks: TensorFlow Lite Edge Impulse OpenCV YOLO object detection 18. Cloud Dashboard Features Dashboard Includes Live traffic density Signal status Historical analytics Congestion heatmaps AI prediction charts Alert logs 19. Future Enhancements Advanced Features Smart City Integration Connect multiple junctions Centralized monitoring AI Camera Vision Vehicle counting Lane analysis Emergency Vehicle Priority Ambulance detection Automatic signal clearance Solar Power System Renewable energy support GSM Backup SMS alerts during internet failure 20. Deployment Guide Step-by-Step Deployment Hardware Assemble circuit Connect sensors Verify LED operation Software Install Arduino IDE Install ESP32 board package Upload source code Cloud Configure ThingSpeak Configure Google Sheets Configure Telegram Bot Import n8n workflow Testing Simulate traffic Verify signal timing Check dashboard updates Confirm Telegram alerts 21. Expected Results Scenario Output Low Traffic Short signal duration Heavy Traffic Extended green signal Congestion Telegram alert Peak Hours AI prediction generated 22. Advantages Reduces traffic congestion Saves fuel Low-cost implementation Real-time monitoring Scalable architecture Supports smart cities 23. Applications Smart city infrastructure Highways Urban intersections Industrial traffic control Campus traffic systems 24. Technologies Used Technology Purpose ESP32 IoT controller n8n Workflow automation Telegram Bot Notifications ThingSpeak Cloud analytics Google Sheets Data logging AI/ML Prediction logic 25. Conclusion This project demonstrates a modern AI-powered intelligent traffic management system using ESP32, IoT cloud platforms, and automation tools. By combining: Real-time vehicle density analysis AI-based adaptive signal control Cloud dashboards Telegram voice notifications Automation workflows …the system provides a scalable foundation for future smart-city traffic infrastructure.

AI Smart Surveillance Robot with Face and Motion Detection

AI Smart Surveillance Robot with Face & Motion Detection ESP32 + AI Agentic IoT + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard
AI Smart Surveillance Robot with Face & Motion Detection ESP32 + AI Agentic IoT + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard 1. Project Overview This project is an AI-powered smart surveillance robot using an ESP32-CAM and IoT automation. The robot can: Detect motion Perform face detection Capture images Send Telegram alerts Send voice notifications Store logs in Google Sheets Upload sensor values to ThingSpeak Trigger AI-based automation via n8n Predict power usage using simple AI logic Provide remote cloud monitoring 2. System Architecture ┌─────────────────┐ │ ESP32-CAM │ │ Motion + Camera │ └────────┬────────┘ │ WiFi ▼ ┌─────────────────┐ │ n8n │ │ Automation Hub │ └──────┬──────────┘ │ ┌────────────────┼────────────────┐ ▼ ▼ ▼ Telegram Bot Google Sheets ThingSpeak Voice Alerts Data Logging Cloud Dashboard │ ▼ AI Notification & Automation Agent 3. Features Smart Surveillance Motion detection using PIR sensor Face detection using ESP32-CAM AI library Intruder image capture AI Automation Event classification Intelligent alert triggering AI power consumption estimation Cloud Features Real-time dashboard Cloud logging Remote monitoring Notifications Telegram instant alerts Telegram voice alerts Sensor event messages 4. Required Components Component Quantity ESP32-CAM Module 1 FTDI Programmer 1 PIR Motion Sensor HC-SR501 1 Servo Motors (Robot movement) 2 L298N Motor Driver 1 DC Gear Motors 2 Ultrasonic Sensor HC-SR04 1 Buzzer 1 Li-ion Battery Pack 1 Voltage Regulator 5V 1 Jumper Wires Many Robot Chassis 1 Breadboard 1 Optional: IR LEDs for night vision Solar charging module Relay module 5. Circuit Connections ESP32-CAM Pin Mapping Device ESP32 Pin PIR OUT GPIO 13 Buzzer GPIO 12 Servo Left GPIO 14 Servo Right GPIO 15 Ultrasonic TRIG GPIO 2 Ultrasonic ECHO GPIO 4 Motor Driver IN1 GPIO 16 Motor Driver IN2 GPIO 17 6. Circuit Schematic (Text Representation) +-------------------+ | ESP32-CAM | | | PIR ---->| GPIO13 | Buzzer ->| GPIO12 | Servo1 ->| GPIO14 | Servo2 ->| GPIO15 | TRIG --->| GPIO2 | ECHO --->| GPIO4 | +-------------------+ │ WiFi ▼ Internet / Router ▼ n8n Automation Server │ ┌──────────┼───────────┐ ▼ ▼ ▼ Telegram GoogleSheet ThingSpeak 7. Working Principle PIR sensor detects movement ESP32 activates camera Face detection algorithm runs Snapshot captured Data sent to n8n webhook n8n: Sends Telegram message Sends voice alert Updates Google Sheets Uploads ThingSpeak data AI logic predicts battery consumption 8. Flowchart START │ ▼ Initialize ESP32 │ ▼ Connect WiFi │ ▼ Detect Motion? ┌────┴─────┐ │ │ NO YES │ │ ▼ ▼ Continue Capture Image Monitoring │ ▼ Face Detection │ ▼ Send to n8n │ ┌───────────┼───────────┐ ▼ ▼ ▼ Telegram Google ThingSpeak Alerts Sheets Upload │ ▼ Voice Notification │ ▼ END 9. ESP32 Source Code (Arduino) #include "WiFi.h" #include "HTTPClient.h" #include "esp_camera.h" const char* ssid = "YOUR_WIFI"; const char* password = "YOUR_PASSWORD"; String webhook = "https://YOUR_N8N/webhook/surveillance"; #define PIR_PIN 13 #define BUZZER 12 void setup() { Serial.begin(115200); pinMode(PIR_PIN, INPUT); pinMode(BUZZER, OUTPUT); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(1000); Serial.println("Connecting..."); } Serial.println("WiFi Connected"); } void loop() { int motion = digitalRead(PIR_PIN); if (motion == HIGH) { digitalWrite(BUZZER, HIGH); HTTPClient http; http.begin(webhook); http.addHeader("Content-Type", "application/json"); String payload = "{\"motion\":\"detected\"}"; int response = http.POST(payload); Serial.println(response); http.end(); delay(5000); digitalWrite(BUZZER, LOW); } delay(500); } 10. ESP32-CAM Face Detection Use the built-in ESP-WHO library. Enable: #define CONFIG_ESP_FACE_DETECT_ENABLED Functions: Face detection Face recognition Object tracking 11. n8n Workflow Overview Workflow Nodes Webhook Trigger IF Motion Detected Telegram Send Message Telegram Voice Notification Google Sheets Append Row ThingSpeak HTTP Request AI Decision Node 12. Example n8n Workflow JSON { "nodes": [ { "name": "Webhook", "type": "n8n-nodes-base.webhook" }, { "name": "Telegram", "type": "n8n-nodes-base.telegram" }, { "name": "Google Sheets", "type": "n8n-nodes-base.googleSheets" } ] } 13. Telegram Bot Setup Step 1 — Create Bot Open Telegram and search: BotFather Official Telegram Bot Commands: /newbot Save: Bot Token Bot Username Step 2 — Get Chat ID Open: Get Telegram Chat ID Bot Step 3 — Test Message API https://api.telegram.org/botBOT_TOKEN/sendMessage?chat_id=CHAT_ID&text=MotionDetected 14. Telegram Voice Notification Use Telegram sendVoice. Generate voice using: Google TTS gTTS Python library ElevenLabs API Example n8n flow: Webhook → AI Text → TTS → Telegram Voice Example alert: "Warning. Motion detected near the entrance." 15. Google Sheets Integration Create Sheet Columns: Timestamp Motion Face Battery Distance Google Cloud Setup Create Google Cloud Project Enable Google Sheets API Create Service Account Download credentials JSON Connect credentials in n8n Useful resources: Google Sheets API Documentation n8n Official Website 16. ThingSpeak Dashboard Setup Create account: ThingSpeak Official Website Fields Field Data Field1 Motion Field2 Battery Field3 Distance Field4 AI Risk Score ESP32 Upload API String url = "http://api.thingspeak.com/update?api_key=APIKEY&field1=1"; 17. AI Power Consumption Prediction Logic Inputs Camera active time WiFi usage Motor activity Alert frequency Formula P=V×I Battery prediction: E=P×t Example AI Logic if motion_events > 50: power_mode = "HIGH" if battery < 20: disable_camera() 18. AI Agentic Automation The AI agent can: Analyze motion frequency Detect suspicious patterns Reduce false alarms Predict battery depletion Trigger emergency alerts 19. Voice Automation Pipeline ESP32 Event │ ▼ n8n Webhook │ ▼ AI Message Generator │ ▼ Text-to-Speech │ ▼ Telegram Voice Alert 20. Security Features Secure HTTPS webhook Telegram authentication API key encryption Cloud access control 21. Future Enhancements AI Upgrades Face recognition database Intruder classification Weapon detection Edge AI object tracking IoT Upgrades GPS tracking Live video streaming MQTT communication Home Assistant integration Robotics Autonomous navigation SLAM mapping Obstacle avoidance AI 22. Deployment Guide Local Deployment Home security robot Office surveillance Warehouse monitoring Cloud Deployment VPS-hosted n8n server Remote dashboard access Multi-device monitoring Recommended platforms: n8n Cloud Google Cloud Platform AWS IoT Core 23. Suggested Folder Structure AI_Surveillance_Robot/ │ ├── ESP32_Code/ ├── n8n_Workflow/ ├── Telegram_Bot/ ├── GoogleSheets/ ├── ThingSpeak/ ├── AI_Logic/ ├── Documentation/ └── Circuit_Diagram/ 24. Estimated Cost Total:₹8000–₹8500 Approx 25. Final Outcome This project creates a: ✅ Smart AI surveillance robot ✅ Cloud-connected IoT security system ✅ Real-time Telegram alert system ✅ AI-powered automation platform ✅ Edge AI + cloud AI hybrid architecture ✅ Expandable smart security ecosystem

AI Smart Railway Track Crack Detection Robot

AI Smart Railway Track Crack Detection Robot Agentic IoT using ESP32 + AI + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Dashboard
AI Smart Railway Track Crack Detection Robot Agentic IoT using ESP32 + AI + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Dashboard 1. Project Overview The AI Smart Railway Track Crack Detection Robot is an intelligent autonomous monitoring system designed to detect cracks and abnormalities in railway tracks using sensors and AI-based logic. The robot continuously scans railway tracks using ultrasonic and vibration sensors. The collected data is processed by an ESP32 microcontroller and transmitted to cloud services through Wi-Fi. The system integrates: ESP32-based IoT controller Crack detection sensors AI-powered anomaly prediction n8n automation workflows Telegram instant alerts Telegram voice notifications Google Sheets logging ThingSpeak cloud dashboard Agentic AI monitoring logic This project can help reduce railway accidents by detecting track faults early and automatically notifying railway authorities. 2. Key Features ✅ Real-time railway crack detection ✅ ESP32 Wi-Fi enabled IoT monitoring ✅ AI-based abnormality prediction ✅ Telegram instant alerts ✅ Telegram voice notifications ✅ Google Sheets automatic logging ✅ ThingSpeak cloud visualization ✅ Autonomous Agentic IoT workflow ✅ Cloud monitoring dashboard ✅ Low-power intelligent operation ✅ Expandable for GPS and camera AI 3. System Architecture Railway Track ↓ Sensors (Ultrasonic + Vibration + IR) ↓ ESP32 Controller ↓ Wi-Fi Cloud APIs / n8n ↓ ┌──────────────────────┐ │ Telegram Bot Alerts │ │ Voice Notifications │ │ Google Sheets Logs │ │ ThingSpeak Dashboard│ └──────────────────────┘ ↓ AI Prediction Engine ↓ Maintenance Decision Support 4. Components List Component Quantity Purpose ESP32 Dev Board 1 Main controller Ultrasonic Sensor HC-SR04 1 Crack distance detection Vibration Sensor SW-420 1 Detect rail vibration anomalies IR Sensor Module 1 Track surface monitoring DC Gear Motors 2 Robot movement L298N Motor Driver 1 Motor control Robot Chassis 1 Mechanical platform Wheels 2 Robot mobility Li-ion Battery Pack 1 Power supply Voltage Regulator 1 Stable voltage Jumper Wires Multiple Connections Breadboard / PCB 1 Circuit assembly Buzzer 1 Local alert LED Indicators 2 Status indication Wi-Fi Router/Hotspot 1 Internet connectivity 5. Working Principle Robot moves along railway track. Ultrasonic sensor continuously measures surface gap. If abnormal distance is detected: Crack condition triggered. ESP32 sends sensor data to: n8n workflow ThingSpeak cloud Google Sheets n8n automation: Generates Telegram alerts Sends voice notifications AI logic predicts: Power consumption Sensor anomaly patterns Maintenance risk score 6. Circuit Schematic Diagram ESP32 Connections ESP32 Pin Connected Device GPIO 5 Ultrasonic Trigger GPIO 18 Ultrasonic Echo GPIO 19 Vibration Sensor GPIO 21 IR Sensor GPIO 25 Motor Driver IN1 GPIO 26 Motor Driver IN2 GPIO 27 Motor Driver IN3 GPIO 14 Motor Driver IN4 GPIO 2 Buzzer 5V Sensors VCC GND Common Ground 7. Flowchart START ↓ Initialize ESP32 & Wi-Fi ↓ Read Sensors ↓ Analyze Crack Condition ↓ Is Crack Detected? ┌───────────────┐ │ YES │ NO ↓ ↓ Send Alerts Continue Monitoring ↓ Upload to Cloud ↓ AI Prediction ↓ Store in Google Sheets ↓ Voice Notification ↓ Continue Monitoring 8. ESP32 Source Code (Arduino IDE) #include #include const char* ssid = "YOUR_WIFI_NAME"; const char* password = "YOUR_WIFI_PASSWORD"; #define TRIG_PIN 5 #define ECHO_PIN 18 #define BUZZER 2 String webhookURL = "YOUR_N8N_WEBHOOK_URL"; void setup() { Serial.begin(115200); pinMode(TRIG_PIN, OUTPUT); pinMode(ECHO_PIN, INPUT); pinMode(BUZZER, OUTPUT); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(1000); Serial.println("Connecting..."); } Serial.println("WiFi Connected"); } float getDistance() { digitalWrite(TRIG_PIN, LOW); delayMicroseconds(2); digitalWrite(TRIG_PIN, HIGH); delayMicroseconds(10); digitalWrite(TRIG_PIN, LOW); long duration = pulseIn(ECHO_PIN, HIGH); float distance = duration * 0.034 / 2; return distance; } void loop() { float distance = getDistance(); Serial.println(distance); if(distance > 15) { digitalWrite(BUZZER, HIGH); if(WiFi.status() == WL_CONNECTED) { HTTPClient http; http.begin(webhookURL); http.addHeader("Content-Type", "application/json"); String payload = "{\"crack\":\"DETECTED\",\"distance\":" + String(distance) + "}"; int httpResponseCode = http.POST(payload); Serial.println(httpResponseCode); http.end(); } } else { digitalWrite(BUZZER, LOW); } delay(3000); } 9. n8n Automation Workflow Workflow Functions The n8n workflow performs: Receives ESP32 webhook data Detects crack event Sends Telegram message Converts text to voice Logs to Google Sheets Updates AI prediction database n8n Workflow Structure Webhook Trigger ↓ IF Crack Detected ↓ ┌───────────────┬────────────────┬────────────────┐ ↓ ↓ ↓ Telegram Bot Google Sheets ThingSpeak API ↓ Text-to-Speech ↓ Telegram Voice Alert n8n Workflow JSON { "nodes": [ { "name": "Webhook", "type": "n8n-nodes-base.webhook" }, { "name": "IF Crack", "type": "n8n-nodes-base.if" }, { "name": "Telegram", "type": "n8n-nodes-base.telegram" }, { "name": "Google Sheets", "type": "n8n-nodes-base.googleSheets" } ] } 10. Telegram Bot Setup Step 1: Create Bot Open Telegram and search: Telegram Search for: BotFather Commands: /start /newbot Copy generated BOT TOKEN. Step 2: Get Chat ID Send a message to your bot. Open: Telegram API GetUpdates Example: https://api.telegram.org/bot/getUpdates Copy chat ID. 11. Telegram Voice Notification Automation Voice Alert Logic When crack detected: "Warning! Railway track crack detected. Immediate inspection required." n8n uses: Google TTS ElevenLabs API Telegram voice upload 12. Google Sheets Integration Create Google Sheet Example columns: Time Distance Crack Status Location Google Cloud Setup Enable: Google Sheets API Google Drive API Create: OAuth credentials Connect Google account in n8n. 13. ThingSpeak Cloud Dashboard Setup Create account on: ThingSpeak Create Channel Fields Field Data Field 1 Distance Field 2 Crack Status Field 3 AI Risk Score ESP32 Upload API Example String url = "http://api.thingspeak.com/update?api_key=YOUR_KEY&field1=" + String(distance); 14. AI Power Consumption Prediction Logic Objective Predict battery usage and optimize robot operation. AI Parameters Parameter Description Motor runtime Robot movement duration Sensor activity Number of readings Wi-Fi transmission Network usage Alert frequency Number of alerts Simple AI Formula Battery prediction: P=V×I Remaining battery estimation: Battery Life= Current Consumption Battery Capacity ​ AI Decision Logic IF battery < 20% Reduce sensor frequency Disable continuous movement Enable low-power mode 15. ThingSpeak AI Analytics ThingSpeak can: Visualize sensor graphs Generate anomaly trends Predict maintenance frequency Monitor robot uptime 16. Future Enhancements Advanced AI Features Computer Vision Add ESP32-CAM Crack image detection using CNN GPS Tracking Real-time robot location GSM Module SMS alerts without Wi-Fi Solar Charging Autonomous outdoor charging Edge AI TinyML on ESP32 Digital Twin Railway virtual monitoring system 17. Deployment Guide Railway Testing Procedure Step 1 Test sensors on small track model. Step 2 Calibrate crack threshold values. Step 3 Deploy on low-speed railway section. Step 4 Monitor cloud dashboard. Step 5 Train AI model using collected data. 18. Safety Considerations Use insulated battery enclosure Waterproof sensor casing Add emergency stop switch Ensure motor speed control Avoid live railway testing without permission 19. Advantages ✅ Low-cost monitoring ✅ Real-time automation ✅ Reduced human inspection ✅ Early fault detection ✅ Cloud-enabled analytics ✅ AI-assisted maintenance 20. Applications Railway safety systems Smart transportation Industrial track monitoring Metro rail maintenance Autonomous inspection robots 21. Project Outcome The system demonstrates how AI + IoT + Automation + Cloud Computing can modernize railway infrastructure using low-cost embedded hardware. The combination of: ESP32 n8n workflows Telegram automation Google Sheets logging ThingSpeak analytics AI prediction creates a complete Agentic Smart Railway Monitoring Ecosystem.

AI Smart Parking System with Empty Slot Detection and Mobile App

AI Smart Parking System with Empty Slot Detection and Mobile App Agentic IoT using ESP32 + AI + n8n + Telegram Voice Alerts + Google Sheets + ThingSpeak
AI Smart Parking System with Empty Slot Detection and Mobile App Agentic IoT using ESP32 + AI + n8n + Telegram Voice Alerts + Google Sheets + ThingSpeak 1. Project Overview This project is an AI-powered Smart Parking Management System that detects empty parking slots using sensors connected to an ESP32. The system uploads parking data to the cloud, automates workflows using n8n, sends Telegram notifications with voice alerts, stores logs in Google Sheets, and visualizes data on ThingSpeak dashboards. The system can: Detect occupied/empty parking slots Display available parking spaces on web/mobile dashboard Send instant Telegram alerts Generate AI-based parking predictions Store historical parking data Trigger voice notifications Predict power usage and parking trends Work as an Agentic IoT automation system 2. System Architecture Ultrasonic/IR Sensors ↓ ESP32 ↓ WiFi ThingSpeak Cloud ↓ n8n ↙ ↓ ↘ Telegram AI Logic Google Sheets Alerts Analysis Data Logging 3. Components List Component Quantity Purpose ESP32 Dev Board 1 Main controller IR Sensors / Ultrasonic Sensors 4 Vehicle detection OLED Display (Optional) 1 Display slot status Buzzer 1 Local alerts LEDs 4 Slot indication Breadboard 1 Connections Jumper Wires Several Wiring 5V Power Supply 1 Power source WiFi Router 1 Internet connectivity 4. Parking Slot Logic Sensor State Slot Status HIGH Empty LOW Occupied 5. Circuit Schematic Diagram IR Sensor 1 → GPIO 13 IR Sensor 2 → GPIO 12 IR Sensor 3 → GPIO 14 IR Sensor 4 → GPIO 27 LED1 → GPIO 18 LED2 → GPIO 19 LED3 → GPIO 21 LED4 → GPIO 22 Buzzer → GPIO 23 VCC → 5V GND → GND 6. Flowchart START ↓ Initialize ESP32 ↓ Connect WiFi ↓ Read Sensors ↓ Check Empty Slots ↓ Upload Data to ThingSpeak ↓ Trigger n8n Webhook ↓ Send Telegram Alert ↓ Store Data in Google Sheets ↓ Run AI Prediction ↓ Repeat 7. ESP32 Source Code (Arduino IDE) #include #include const char* ssid = "YOUR_WIFI_NAME"; const char* password = "YOUR_WIFI_PASSWORD"; String apiKey = "THINGSPEAK_API_KEY"; #define S1 13 #define S2 12 #define S3 14 #define S4 27 void setup() { Serial.begin(115200); pinMode(S1, INPUT); pinMode(S2, INPUT); pinMode(S3, INPUT); pinMode(S4, INPUT); WiFi.begin(ssid, password); while(WiFi.status() != WL_CONNECTED) { delay(1000); Serial.println("Connecting..."); } Serial.println("WiFi Connected"); } void loop() { int slot1 = digitalRead(S1); int slot2 = digitalRead(S2); int slot3 = digitalRead(S3); int slot4 = digitalRead(S4); int emptySlots = 0; if(slot1 == HIGH) emptySlots++; if(slot2 == HIGH) emptySlots++; if(slot3 == HIGH) emptySlots++; if(slot4 == HIGH) emptySlots++; if(WiFi.status() == WL_CONNECTED) { HTTPClient http; String url = "http://api.thingspeak.com/update?api_key=" + apiKey + "&field1=" + String(slot1) + "&field2=" + String(slot2) + "&field3=" + String(slot3) + "&field4=" + String(slot4) + "&field5=" + String(emptySlots); http.begin(url); int httpCode = http.GET(); Serial.println(httpCode); http.end(); } delay(15000); } 8. ThingSpeak Cloud Dashboard Setup Create Channel Create account in ThingSpeak Create new channel Add fields: Field Description Field1 Slot1 Field2 Slot2 Field3 Slot3 Field4 Slot4 Field5 Empty Slots Copy Write API Key Paste into ESP32 code 9. n8n Automation Workflow Features Receives data from ThingSpeak Sends Telegram notifications Converts alerts into voice messages Updates Google Sheets Performs AI prediction logic Install n8n n8n Official Website 10. n8n Workflow JSON { "nodes": [ { "name": "Webhook", "type": "n8n-nodes-base.webhook", "parameters": { "path": "parking-data", "httpMethod": "POST" } }, { "name": "Telegram", "type": "n8n-nodes-base.telegram", "parameters": { "text": "Parking Slot Updated" } }, { "name": "Google Sheets", "type": "n8n-nodes-base.googleSheets", "parameters": { "operation": "append" } } ] } 11. Telegram Bot Setup Create Bot Open Telegram Search for Telegram Search: @BotFather Create bot using: /newbot Copy BOT TOKEN Get Chat ID Send message to your bot then open: https://api.telegram.org/bot/getUpdates 12. Telegram Voice Notification Automation Workflow ESP32 → n8n → Text-to-Speech → Telegram Voice Message Example Voice Alert "Attention! Only two parking slots are available." TTS Services You can use: Google Text-to-Speech ElevenLabs 13. Google Sheets Integration Setup Steps Create sheet in Google Sheets Columns: | Timestamp | Slot1 | Slot2 | Slot3 | Slot4 | Empty Slots | Connect Google account in n8n Use Append Row operation 14. AI Power Consumption Prediction Logic The AI logic predicts: Peak parking usage Low-usage hours ESP32 power consumption trends Expected occupancy patterns Prediction Formula Using moving average: P avg ​ = n P 1 ​ +P 2 ​ +P 3 ​ +⋯+P n ​ ​ Where: P avg ​ = average power P n ​ = sensor power readings Occupancy Prediction O t ​ = n ∑ i=1 n ​ S i ​ ​ Where: O t ​ = predicted occupancy S i ​ = slot occupancy values 15. AI Agent Features The Agentic IoT system can: Analyze parking availability Automatically notify users Predict congestion Trigger maintenance alerts Generate smart reports Recommend optimal parking usage 16. Web Dashboard Features Dashboard Displays Total parking slots Empty slots Occupied slots Real-time sensor status Historical graphs AI predictions 17. Mobile App Features You can create mobile app using: MIT App Inventor Flutter Blynk IoT Platform 18. Advanced Enhancements Additions AI Camera Detection Use: ESP32-CAM YOLO Object Detection License Plate Recognition Use: OCR OpenCV Cloud Database Use: Firebase MongoDB GPS Parking Navigation Guide drivers to empty slots QR Ticket System Automatic billing system 19. Deployment Guide Hardware Deployment Install sensors in parking area Use waterproof casing Ensure stable WiFi coverage Software Deployment Flash ESP32 code Configure ThingSpeak API Deploy n8n workflow Connect Telegram bot Test notifications 20. Testing Procedure Test Expected Result Vehicle enters Slot occupied Vehicle exits Slot empty Empty slot count Updates live Telegram alert Received instantly Google Sheet Data appended ThingSpeak graph Updated 21. Real-Time Notification Examples Telegram Text Alert 🚗 Parking Update: Available Slots: 2 Occupied Slots: 2 Voice Alert "Parking area almost full. Only one slot remaining." 22. Advantages of This Project Smart city ready Low-cost implementation Real-time monitoring AI-driven automation Scalable architecture Cloud enabled Mobile accessible 23. Applications Shopping malls Smart cities Colleges Hospitals Airports Offices Residential parking 24. Future Scope Edge AI deployment Solar-powered ESP32 Machine learning analytics Multi-floor parking management Face recognition entry Autonomous vehicle integration 25. Conclusion This AI Smart Parking System combines: ESP32 IoT hardware AI analytics Cloud dashboards n8n automation Telegram alerts Voice notifications Google Sheets logging to create a complete smart parking ecosystem suitable for modern smart-city applications.

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

AI Smart Helmet for Accident Detection and Rider Safety

AI Smart Helmet for Accident Detection and Rider Safety ESP32 + Agentic IoT + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Dashboard
AI Smart Helmet for Accident Detection and Rider Safety ESP32 + Agentic IoT + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Dashboard 1. Project Overview This project is an AI-powered Smart Helmet System designed to improve rider safety using: ESP32 Crash detection sensors Helmet wearing detection Alcohol detection GPS tracking Cloud IoT dashboard n8n AI automation Telegram voice alerts Google Sheets logging ThingSpeak monitoring The helmet continuously monitors rider conditions and accident events. If an accident occurs: ESP32 detects crash/fall GPS location captured Data uploaded to ThingSpeak n8n automation triggered Telegram voice + text alerts sent Emergency contact notified Data stored in Google Sheets AI predicts battery/power consumption patterns 2. Features Core Features ✅ Accident detection ✅ Helmet wearing detection ✅ Alcohol detection ✅ Rider motion monitoring ✅ GPS live location ✅ Emergency SOS alerts ✅ Telegram voice notifications ✅ Google Sheets logging ✅ ThingSpeak cloud dashboard ✅ AI-based power usage prediction ✅ Real-time IoT monitoring 3. System Architecture Helmet Sensors ↓ ESP32 Controller ↓ WiFi / Internet ↓ ThingSpeak Cloud ↓ n8n Automation Server ↓ ├── Telegram Bot Alerts ├── Telegram Voice Alerts ├── Google Sheets Logging └── AI Agent Processing 4. Components List Component Quantity Purpose ESP32 Dev Board 1 Main controller MPU6050 Accelerometer + Gyroscope 1 Accident/fall detection MQ3 Alcohol Sensor 1 Alcohol detection GPS Module NEO-6M 1 Live location IR Sensor 1 Helmet wear detection Buzzer 1 Local alarm LED Indicators 2 Status indication Push Button 1 Emergency SOS 18650 Battery 1 Portable power TP4056 Charging Module 1 Battery charging Jumper Wires — Connections Helmet 1 Mounting platform 5. Working Principle Accident Detection The MPU6050 detects: Sudden impact High acceleration Abnormal tilt angle If threshold exceeds: Impact > 2.5g OR Tilt angle > 60° then accident event triggered. Helmet Detection IR sensor checks whether helmet is worn. If not worn: Buzzer activates Engine relay can remain OFF Alcohol Detection MQ3 detects alcohol concentration. If alcohol level exceeds threshold: Warning alert generated Vehicle ignition can be disabled GPS Tracking GPS module continuously updates: Latitude Longitude Used in emergency alerts. 6. Circuit Connections ESP32 Pin Mapping Module ESP32 Pin MPU6050 SDA GPIO21 MPU6050 SCL GPIO22 MQ3 Analog GPIO34 IR Sensor GPIO27 GPS TX GPIO16 GPS RX GPIO17 Buzzer GPIO25 LED GPIO26 SOS Button GPIO14 7. Circuit Schematic Diagram +------------------+ | ESP32 | | | MPU6050 SDA | GPIO21 | MPU6050 SCL | GPIO22 | MQ3 OUT ----| GPIO34 | IR Sensor --| GPIO27 | GPS TX -----| GPIO16 | GPS RX -----| GPIO17 | Buzzer -----| GPIO25 | LED --------| GPIO26 | SOS Button -| GPIO14 | +------------------+ 8. Flowchart START ↓ Initialize Sensors ↓ Connect WiFi ↓ Read Sensor Data ↓ Helmet Worn? ┌───────┴────────┐ NO YES ↓ ↓ Alert Check Alcohol ↓ Alcohol Detected? ┌─────┴─────┐ YES NO ↓ ↓ Warning Monitor MPU6050 ↓ Accident Detected? ┌────┴────┐ YES NO ↓ ↓ Send Cloud Data Loop ↓ Trigger n8n Workflow ↓ Telegram + Voice + Sheets ↓ END 9. ESP32 Source Code (Arduino IDE) #include #include #include #include #include #include MPU6050 mpu; TinyGPSPlus gps; HardwareSerial gpsSerial(1); const char* ssid = "YOUR_WIFI"; const char* password = "YOUR_PASSWORD"; String apiKey = "THINGSPEAK_API_KEY"; #define MQ3_PIN 34 #define IR_PIN 27 #define BUZZER 25 #define LED 26 float ax, ay, az; void setup() { Serial.begin(115200); pinMode(IR_PIN, INPUT); pinMode(BUZZER, OUTPUT); pinMode(LED, OUTPUT); Wire.begin(); mpu.initialize(); gpsSerial.begin(9600, SERIAL_8N1, 16, 17); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println("WiFi Connected"); } void loop() { mpu.getAcceleration(&ax, &ay, &az); float impact = sqrt(ax * ax + ay * ay + az * az) / 16384.0; int alcohol = analogRead(MQ3_PIN); int helmet = digitalRead(IR_PIN); while (gpsSerial.available()) { gps.encode(gpsSerial.read()); } double lat = gps.location.lat(); double lng = gps.location.lng(); if (helmet == LOW) { digitalWrite(BUZZER, HIGH); } if (alcohol > 2500) { Serial.println("Alcohol Detected"); } if (impact > 2.5) { digitalWrite(BUZZER, HIGH); digitalWrite(LED, HIGH); if (WiFi.status() == WL_CONNECTED) { HTTPClient http; String url = "http://api.thingspeak.com/update?api_key=" + apiKey + "&field1=" + String(impact) + "&field2=" + String(lat, 6) + "&field3=" + String(lng, 6); http.begin(url); int httpCode = http.GET(); Serial.println(httpCode); http.end(); } } delay(2000); } 10. ThingSpeak Cloud Setup Create Channel Go to: ThingSpeak Create fields: Field Data Field 1 Impact Force Field 2 Latitude Field 3 Longitude Field 4 Alcohol Level Field 5 Helmet Status Copy: Write API Key Channel ID 11. n8n Automation Workflow Install n8n Use: n8n Official Website Workflow Logic ThingSpeak Webhook ↓ IF Accident Detected ↓ Generate AI Summary ↓ Telegram Message ↓ Telegram Voice Alert ↓ Google Sheets Logging 12. n8n Workflow JSON { "nodes": [ { "parameters": {}, "name": "Webhook", "type": "n8n-nodes-base.webhook", "typeVersion": 1, "position": [250, 300] }, { "parameters": { "chatId": "YOUR_CHAT_ID", "text": "🚨 Accident Detected!" }, "name": "Telegram", "type": "n8n-nodes-base.telegram", "typeVersion": 1, "position": [500, 300] } ], "connections": { "Webhook": { "main": [ [ { "node": "Telegram", "type": "main", "index": 0 } ] ] } } } 13. Telegram Bot Setup Step 1 — Create Bot Open: BotFather Telegram Bot Setup Commands: /newbot Copy: BOT TOKEN Step 2 — Get Chat ID Open: https://api.telegram.org/bot/getUpdates Copy chat ID. 14. Telegram Voice Notification Automation Method n8n converts alert text to speech using: Google TTS ElevenLabs API gTTS Python API Voice Message Example: Emergency Alert. Accident detected. Location shared to emergency contacts. 15. Google Sheets Integration Create spreadsheet columns: Timestamp Impact Latitude Longitude Alcohol Helmet In n8n: Google Sheets Node ↓ Append Row Useful for: Analytics Accident history AI training dataset 16. AI Power Consumption Prediction Logic Objective Predict remaining battery life. Inputs WiFi usage GPS activity Sensor sampling rate Alert frequency AI Formula Simple linear prediction: Battery Remaining=Battery Capacity−(WiFi+GPS+Sensor+Alert Power)×Time Advanced AI Future model: TinyML Edge AI LSTM battery forecasting 17. ThingSpeak Dashboard Widgets Add widgets: GPS location map Impact graph Helmet status Alcohol level Battery level 18. AI Agentic IoT Features AI Agent Responsibilities The AI agent can: ✅ Analyze accidents ✅ Predict dangerous driving ✅ Detect battery anomalies ✅ Send smart alerts ✅ Recommend charging times ✅ Generate rider safety reports 19. Future Enhancements Hardware GSM module Camera module Air quality sensor Heartbeat sensor Voice assistant AI Enhancements TinyML crash classification Rider fatigue detection Computer vision Edge AI processing Predictive maintenance 20. Deployment Guide Helmet Assembly Mount: MPU6050 at helmet center GPS on top side ESP32 rear compartment Battery in protected enclosure Power Management Use: 5V regulated supply Deep sleep mode Auto power shutdown Waterproofing Recommended: ABS enclosure Silicone seal Shockproof foam 21. Testing Procedure Test Cases Test Expected Result Helmet removed Buzzer ON Alcohol detected Warning Sudden fall Alert triggered GPS unavailable Retry Internet OFF Store locally 22. Estimated Cost Component Approx Cost ESP32 ₹500 MPU6050 ₹150 GPS Module ₹450 MQ3 Sensor ₹120 Battery ₹300 Miscellaneous ₹500 Total Estimated Cost ₹2000–₹3000 23. Applications Smart transportation Rider safety Fleet management Delivery services Emergency response systems Insurance telematics 24. Conclusion This project combines: IoT AI Cloud automation ESP32 embedded systems n8n workflows Telegram alerts Real-time monitoring to build a next-generation AI Smart Helmet Safety System capable of reducing accident response time and improving rider safety using intelligent automation. Useful Resources ESP32 Official Documentation Arduino IDE ThingSpeak Platform n8n Documentation Telegram Bot API Google Sheets API

Tuesday, 26 May 2026

AI Smart Health Monitoring System with Disease Prediction

AI Smart Health Monitoring System with Disease Prediction AI-Powered ESP32 + Agentic IoT + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard
1. Project Overview This project is an advanced AI-enabled Smart Health Monitoring System using: Espressif Systems ESP32 IoT cloud monitoring AI disease prediction logic Agentic automation using n8n Telegram voice notifications Google Sheets data logging ThingSpeak cloud analytics dashboard The system continuously monitors: Heart Rate SpO₂ (Blood Oxygen) Body Temperature ECG (optional) Blood Pressure (optional simulated) Motion/Fall Detection AI logic predicts possible diseases such as: Fever Hypoxia Tachycardia Bradycardia Stress Cardiac Risk When abnormal values are detected: ESP32 uploads sensor data to cloud n8n automation triggers AI logic Telegram bot sends: Text alert Voice alert Data stored in Google Sheets ThingSpeak dashboard visualizes health trends 2. System Architecture Sensors → ESP32 → WiFi → ThingSpeak Cloud ↓ n8n Webhook ↓ AI Prediction Logic ↓ ┌───────────────┴───────────────┐ ↓ ↓ Telegram Alerts Google Sheets Voice + Text Alerts Health Logs 3. Hardware Components List Component Quantity Purpose ESP32 Dev Board 1 Main controller MAX30102 Pulse Oximeter 1 Heart rate + SpO₂ DS18B20 Temperature Sensor 1 Body temperature AD8232 ECG Sensor Optional ECG monitoring MPU6050 Optional Fall detection OLED Display SSD1306 1 Live display Breadboard 1 Prototyping Jumper Wires Several Connections USB Cable 1 Programming 5V Power Supply 1 Power source 4. Circuit Schematic Diagram ESP32 Connections MAX30102 MAX30102 ESP32 VIN 3.3V GND GND SDA GPIO21 SCL GPIO22 DS18B20 DS18B20 ESP32 VCC 3.3V GND GND DATA GPIO4 Use 4.7kΩ pull-up resistor between DATA and VCC. OLED Display OLED ESP32 VCC 3.3V GND GND SDA GPIO21 SCL GPIO22 5. Flowchart START ↓ Initialize Sensors ↓ Connect WiFi ↓ Read Sensor Data ↓ AI Health Analysis ↓ Abnormal? ┌───────┴────────┐ YES NO ↓ ↓ Send Alert Upload Data ↓ ↓ Telegram Bot ThingSpeak ↓ ↓ Google Sheets Logging ↓ Repeat Loop 6. ESP32 Source Code (Arduino IDE) Required Libraries Install from Arduino Library Manager: WiFi.h HTTPClient.h MAX30105 Adafruit SSD1306 OneWire DallasTemperature ESP32 Code #include #include #include const char* ssid = "YOUR_WIFI"; const char* password = "YOUR_PASSWORD"; String apiKey = "THINGSPEAK_API_KEY"; float temperature = 0; int heartRate = 0; int spo2 = 0; void setup() { Serial.begin(115200); WiFi.begin(ssid, password); while(WiFi.status() != WL_CONNECTED){ delay(1000); Serial.println("Connecting..."); } Serial.println("WiFi Connected"); } void loop() { // Simulated Sensor Values temperature = random(36, 39); heartRate = random(60, 130); spo2 = random(85, 100); Serial.println("Uploading Data"); if(WiFi.status()== WL_CONNECTED){ HTTPClient http; String url = "http://api.thingspeak.com/update?api_key=" + apiKey + "&field1=" + String(temperature) + "&field2=" + String(heartRate) + "&field3=" + String(spo2); http.begin(url); int httpCode = http.GET(); Serial.println(httpCode); http.end(); } // AI Alert Condition if(temperature > 38 || spo2 < 90 || heartRate > 120){ sendAlert(); } delay(15000); } void sendAlert(){ HTTPClient http; String webhook = "YOUR_N8N_WEBHOOK_URL"; http.begin(webhook); http.addHeader("Content-Type", "application/json"); String json = "{"; json += "\"temperature\":" + String(temperature) + ","; json += "\"heartRate\":" + String(heartRate) + ","; json += "\"spo2\":" + String(spo2); json += "}"; int response = http.POST(json); Serial.println(response); http.end(); } 7. Disease Prediction Logic AI Rule-Based Prediction Condition Prediction Temp > 38°C Fever SpO₂ < 90% Respiratory Risk HR > 120 Tachycardia HR < 50 Bradycardia Temp + HR High Infection Risk ECG Abnormal Cardiac Alert AI Formula Risk Score=0.4(Temperature)+0.3(Heart Rate)+0.3(100−SpO 2 ​ ) Decision Threshold Risk Score > 75 → Critical Risk Score 50–75 → Moderate Risk Score < 50 → Normal 8. n8n Workflow Automation Use official website: n8n Official Website Workflow Nodes Webhook ↓ IF Node (Check Critical Values) ↓ Telegram Node ↓ Google Sheets Node ↓ Text-to-Speech API ↓ Telegram Voice Message n8n Workflow JSON { "nodes": [ { "name": "Webhook", "type": "n8n-nodes-base.webhook" }, { "name": "IF", "type": "n8n-nodes-base.if" }, { "name": "Telegram", "type": "n8n-nodes-base.telegram" }, { "name": "Google Sheets", "type": "n8n-nodes-base.googleSheets" } ] } 9. Telegram Bot Setup Use: Telegram Official Website Steps Open Telegram Search: Telegram BotFather Create new bot: /newbot Copy Bot Token Add token in n8n Telegram node 10. Google Sheets Integration Use: Google Sheets Sheet Columns Timestamp Temp HR SpO₂ Disease Prediction Integration Steps Create spreadsheet Enable Google API credentials Connect Google account in n8n Append sensor data automatically 11. ThingSpeak Cloud Dashboard Setup Use: ThingSpeak Official Website Setup Steps Create ThingSpeak account Create New Channel Add Fields: Temperature Heart Rate SpO₂ Copy: Write API Key Insert into ESP32 code Dashboard Widgets Live Temperature Graph Heart Rate Trend Oxygen Saturation Chart AI Risk Gauge 12. Voice Notification Automation Workflow Critical Alert ↓ n8n Trigger ↓ Generate TTS Audio ↓ Telegram Voice Message Example Voice Alert Warning. Patient oxygen level is critically low. Immediate medical attention required. 13. Advanced AI Features Future AI Enhancements Machine Learning Use: Random Forest SVM Neural Networks Deep Learning Predict: Heart disease Diabetes Sleep apnea Edge AI Deploy TinyML directly on ESP32. 14. Cloud Database Options Platform Purpose Firebase Realtime database MongoDB Atlas Medical records AWS IoT Enterprise IoT Azure IoT Hub Scalable monitoring 15. Security Features HTTPS encryption Token authentication Secure cloud APIs Patient data privacy Access control 16. Future Enhancements Hardware GPS tracking GSM alerts Camera monitoring Smartwatch integration Software AI chatbot doctor Mobile app Predictive analytics Remote doctor dashboard Multi-patient monitoring 17. Deployment Guide Local Deployment Arduino IDE upload Local WiFi Free cloud platforms Production Deployment Dedicated server MQTT broker SSL security Dockerized n8n Database backup 18. Applications Remote patient monitoring Elderly care ICU monitoring Smart hospitals Home healthcare Rural telemedicine 19. Final Output Features ✅ Real-time health monitoring ✅ AI disease prediction ✅ Telegram text alerts ✅ Telegram voice notifications ✅ Google Sheets logging ✅ ThingSpeak visualization ✅ ESP32 cloud IoT ✅ n8n intelligent automation ✅ Agentic AI workflows ✅ Future-ready architecture 20. Recommended Software Tools Software Purpose Arduino IDE ESP32 programming n8n Automation Postman API testing ThingSpeak Cloud dashboard Google Sheets Data logging 21. Conclusion This project combines: AI IoT Cloud computing Automation Healthcare analytics into a powerful next-generation smart healthcare ecosystem using ESP32 and Agentic AI automation. It is ideal for: Engineering final-year projects Research prototypes Healthcare startups Smart hospital systems Remote patient monitoring platforms

AI Smart Garbage Monitoring and Collection System with Route Optimization

AI Smart Garbage Monitoring and Collection System with Route Optimization
AI Smart Garbage Monitoring and Collection System with Route Optimization An intelligent waste-management platform using an ESP32-based IoT node, AI-assisted analytics, cloud dashboards, automated workflows, and Telegram voice alerts. The system monitors garbage bin levels, predicts overflow, optimizes collection schedules, and sends real-time notifications. 1. Project Overview Objective Build a smart garbage monitoring system that: Detects garbage level in bins Monitors temperature and harmful gas Sends data to cloud dashboards Stores logs in Google Sheets Uses AI logic to predict overflow timing Sends Telegram text + voice alerts Supports route optimization for garbage trucks Automates workflows using n8n 2. System Architecture Hardware Layer ESP32 WiFi microcontroller Ultrasonic sensor for fill level Gas sensor for methane/ammonia Temperature sensor Optional GPS module Cloud Layer ThingSpeak cloud dashboard Google Sheets data logging Telegram bot notifications n8n automation workflows AI Layer Garbage fill prediction Pickup schedule estimation Route optimization logic 3. Components List Component Quantity Purpose ESP32 Dev Board 1 Main controller HC-SR04 Ultrasonic Sensor 1 Measure garbage level MQ-135 Gas Sensor 1 Detect harmful gases DHT11/DHT22 Sensor 1 Temperature & humidity Buzzer 1 Local alert LED Indicators 2 Status indicators Breadboard 1 Prototyping Jumper Wires Several Connections 5V Power Supply 1 Power source GPS Module NEO-6M (Optional) 1 Location tracking SIM800L (Optional) 1 GSM backup Garbage Bin Model 1 Physical implementation 4. Working Principle Step-by-Step Operation ESP32 reads garbage level using ultrasonic sensor. Gas sensor checks for harmful gases. Temperature sensor monitors heat/fire risk. ESP32 sends data to ThingSpeak. n8n fetches sensor data. AI logic predicts overflow timing. Google Sheets logs all records. Telegram bot sends alerts: Bin Full Fire Risk Toxic Gas Alert Collection Recommendation Voice alerts are generated automatically. Route optimization suggests best collection order. 5. Circuit Connections HC-SR04 → ESP32 HC-SR04 ESP32 VCC 5V GND GND TRIG GPIO 5 ECHO GPIO 18 MQ135 → ESP32 MQ135 ESP32 VCC 5V GND GND AO GPIO 34 DHT11 → ESP32 DHT11 ESP32 VCC 3.3V GND GND DATA GPIO 4 Buzzer Buzzer ESP32 + GPIO 23 - GND 6. Circuit Schematic Diagram +------------------+ | ESP32 | | | HC-SR04 TRIG --> GPIO5 | HC-SR04 ECHO --> GPIO18 | MQ135 Analog --> GPIO34 | DHT11 DATA ----> GPIO4 | Buzzer --------> GPIO23 | | | +------------------+ | WiFi Cloud | ------------------------------------------------ | | | | ThingSpeak Google Sheets Telegram n8n Dashboard Logs Alerts Workflow 7. System Flowchart START | Initialize Sensors | Connect WiFi | Read Sensor Data | Calculate Garbage Level | Check Thresholds | Send Data to ThingSpeak | Trigger n8n Workflow | Store in Google Sheets | AI Prediction Logic | Send Telegram Alerts | Voice Notification | Repeat 8. ESP32 Source Code (Arduino IDE) #include #include #include "DHT.h" #define TRIG_PIN 5 #define ECHO_PIN 18 #define MQ135_PIN 34 #define DHTPIN 4 #define DHTTYPE DHT11 #define BUZZER 23 const char* ssid = "YOUR_WIFI_NAME"; const char* password = "YOUR_WIFI_PASSWORD"; String apiKey = "YOUR_THINGSPEAK_API_KEY"; DHT dht(DHTPIN, DHTTYPE); void setup() { Serial.begin(115200); pinMode(TRIG_PIN, OUTPUT); pinMode(ECHO_PIN, INPUT); pinMode(BUZZER, OUTPUT); dht.begin(); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(1000); Serial.println("Connecting..."); } Serial.println("WiFi Connected"); } float getDistance() { digitalWrite(TRIG_PIN, LOW); delayMicroseconds(2); digitalWrite(TRIG_PIN, HIGH); delayMicroseconds(10); digitalWrite(TRIG_PIN, LOW); long duration = pulseIn(ECHO_PIN, HIGH); float distance = duration * 0.034 / 2; return distance; } void loop() { float distance = getDistance(); float binHeight = 30.0; float garbageLevel = ((binHeight - distance) / binHeight) * 100; int gasValue = analogRead(MQ135_PIN); float temp = dht.readTemperature(); Serial.print("Garbage Level: "); Serial.println(garbageLevel); if (garbageLevel > 80 || gasValue > 2500 || temp > 45) { digitalWrite(BUZZER, HIGH); } else { digitalWrite(BUZZER, LOW); } if (WiFi.status() == WL_CONNECTED) { HTTPClient http; String url = "http://api.thingspeak.com/update?api_key=" + apiKey + "&field1=" + String(garbageLevel) + "&field2=" + String(gasValue) + "&field3=" + String(temp); http.begin(url); int httpCode = http.GET(); Serial.println(httpCode); http.end(); } delay(15000); } 9. ThingSpeak Cloud Dashboard Setup Using ThingSpeak Steps Create account Create New Channel Add fields: Garbage Level Gas Sensor Temperature Copy Write API Key Paste in ESP32 code Create: Gauge charts Line graphs Alerts 10. Google Sheets Integration Using: n8n Google Sheets Node Google Cloud API Sheet Columns Timestamp Bin ID Garbage % Gas Temp Status 11. Telegram Bot Setup Using Telegram BotFather Steps Open Telegram Search: /BotFather Create Bot: /newbot Copy Bot Token Example: 123456:ABCDEFxxxx Get Chat ID using: https://api.telegram.org/bot/getUpdates 12. Telegram Voice Alert Automation Example Voice Message Warning! Smart garbage bin number 5 is almost full. Immediate collection required. n8n Voice Generation Flow Workflow Logic ThingSpeak Trigger | Check Threshold | Generate AI Text | Convert Text to Speech | Send Telegram Voice Message 13. n8n Automation Workflow Using n8n Automation Features Trigger from ThingSpeak API AI prediction node Telegram notifications Google Sheets logging Voice synthesis automation Sample n8n Workflow JSON { "nodes": [ { "name": "ThingSpeak Trigger", "type": "httpRequest", "position": [200, 300] }, { "name": "Check Threshold", "type": "if", "position": [400, 300] }, { "name": "Telegram Alert", "type": "telegram", "position": [600, 300] }, { "name": "Google Sheets", "type": "googleSheets", "position": [800, 300] } ] } 14. AI Power Consumption Prediction Logic Purpose Predict: Battery usage Sensor activity load Communication power drain AI Logic Formula Power estimation: P=V×I Battery life: Battery Life= Current Consumption Battery Capacity ​ AI Prediction Strategy The system learns: Peak garbage hours Frequency of alerts Sensor activity patterns Then predicts: Next overflow time Energy-saving sleep intervals Efficient upload frequency 15. Route Optimization Logic Goal Reduce: Fuel consumption Travel time Overflow incidents Inputs GPS coordinates Bin fill levels Traffic data Collection priorities AI Logic Priority Score: Priority=0.6(Fill Level)+0.3(Gas Risk)+0.1(Temperature) Route optimization can use: Dijkstra Algorithm A* Pathfinding Google Maps API 16. Example Alert Messages Telegram Text Alert 🚨 Garbage Bin Alert Bin ID: BIN-04 Level: 92% Gas Risk: HIGH Action Required: Immediate Pickup Voice Alert Attention. Garbage bin four is critically full. Collection vehicle dispatch required immediately. 17. Future Enhancements AI Improvements Machine learning overflow prediction Seasonal waste pattern analysis Smart route clustering Hardware Enhancements Solar-powered bins Camera-based waste detection AI image classification RFID-based citizen tracking Software Enhancements Mobile app Web admin dashboard Firebase real-time database AI chatbot assistant 18. Deployment Guide Small Scale Apartment complexes Schools Campuses Medium Scale Smart city pilot Municipal wards Large Scale Entire city waste management AI fleet management integration 19. Advantages Reduces overflow Saves fuel costs Real-time monitoring Improves hygiene Supports smart cities Enables predictive maintenance 20. Expected Output The system provides: Real-time garbage status Cloud analytics Automated AI alerts Voice notifications Route planning recommendations Historical data analysis 21. Software & Platforms Used Platform Purpose Arduino IDE ESP32 programming ThingSpeak Cloud dashboard n8n Automation Telegram Notifications Google Sheets Data storage Google Maps API Route optimization 22. Conclusion The AI Smart Garbage Monitoring and Collection System combines IoT, cloud computing, automation, and AI analytics to modernize waste management. Using ESP32 sensors, n8n automation, Telegram voice alerts, Google Sheets logging, and ThingSpeak visualization, the system enables efficient, scalable, and intelligent garbage collection operations suitable for smart cities and sustainable urban development.

AI Smart Energy Meter with Power Consumption Prediction

AI Smart Energy Meter with Power Consumption Prediction ESP32 + Agentic AI IoT + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak
1. Project Overview The AI Smart Energy Meter is an advanced IoT-based electricity monitoring system that measures real-time power consumption using an ESP32 microcontroller and uploads the data to cloud platforms for monitoring, analytics, and AI-based prediction. The system integrates: ESP32 Wi-Fi microcontroller Current & voltage sensing Cloud IoT dashboard AI power usage prediction n8n workflow automation Telegram voice alert notifications Google Sheets logging ThingSpeak cloud analytics This project demonstrates a complete Agentic AI IoT architecture, where the system can: Monitor electricity usage Predict future consumption Detect overload conditions Send smart alerts automatically Store historical data Trigger automation workflows 2. Objectives The main objectives are: Measure voltage, current, power, and energy consumption Upload live data to cloud platforms Predict future energy usage using AI logic Send Telegram notifications and voice alerts Store records in Google Sheets Automate workflows using n8n Create a scalable smart energy monitoring solution 3. Features Real-Time Monitoring Voltage monitoring Current monitoring Power calculation Energy consumption tracking IoT Cloud Dashboard Live cloud updates Graphical visualization Remote monitoring AI Prediction Predict next-hour/day consumption Detect abnormal energy usage Intelligent recommendations Telegram Alerts Instant notifications Voice warning messages Overload alerts Device status alerts Google Sheets Logging Automatic data storage Historical analytics Exportable records n8n Automation Workflow automation Event-based triggers Smart decision engine 4. Hardware Components Component Quantity ESP32 Dev Board 1 ACS712 Current Sensor 1 ZMPT101B Voltage Sensor 1 OLED Display (Optional) 1 Relay Module 1 Breadboard 1 Jumper Wires Several Power Supply 5V Wi-Fi Router 1 5. Software Requirements Software Purpose Arduino IDE ESP32 Programming n8n Workflow Automation Telegram Bot API Alerts ThingSpeak Cloud Dashboard Google Sheets API Data Logging Python/AI Logic Prediction Model 6. System Architecture Voltage/Current Sensors ↓ ESP32 ↓ Wi-Fi Internet ↓ ThingSpeak ↓ n8n ↙ ↓ ↘ Telegram AI Google Sheets Alerts Prediction Storage 7. Working Principle Step 1: Sensor Reading The ESP32 reads: Voltage from ZMPT101B Current from ACS712 Step 2: Power Calculation P=V×I Where: P = Power (Watts) V = Voltage I = Current Step 3: Energy Consumption E=P×t Where: E = Energy (Wh) t = Time Step 4: Upload to Cloud ESP32 sends data to: ThingSpeak n8n Webhook Step 5: AI Analysis n8n processes: Average usage Peak load Future prediction Abnormal pattern detection Step 6: Alerts If consumption exceeds threshold: Telegram message sent Voice alert generated Google Sheets updated 8. Circuit Connections ACS712 to ESP32 ACS712 ESP32 VCC 5V GND GND OUT GPIO34 ZMPT101B to ESP32 ZMPT101B ESP32 VCC 5V GND GND OUT GPIO35 Relay Module Relay ESP32 IN GPIO26 VCC 5V GND GND 9. Schematic Diagram (Text Format) AC Load | Current Sensor | Voltage Sensor | ESP32 / | \ WiFi Relay OLED | Internet | ThingSpeak | n8n / | \ Telegram AI GoogleSheet 10. ESP32 Arduino Code #include #include const char* ssid = "YOUR_WIFI"; const char* password = "YOUR_PASSWORD"; String apiKey = "THINGSPEAK_API_KEY"; float voltage = 230.0; float current = 0.5; float power; void setup() { Serial.begin(115200); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(1000); Serial.println("Connecting..."); } Serial.println("WiFi Connected"); } void loop() { current = analogRead(34) * (5.0 / 4095.0); power = voltage * current; if(WiFi.status()== WL_CONNECTED){ HTTPClient http; String url = "http://api.thingspeak.com/update?api_key=" + apiKey + "&field1=" + String(voltage) + "&field2=" + String(current) + "&field3=" + String(power); http.begin(url); int httpCode = http.GET(); Serial.println(httpCode); http.end(); } Serial.print("Voltage: "); Serial.println(voltage); Serial.print("Current: "); Serial.println(current); Serial.print("Power: "); Serial.println(power); delay(15000); } 11. n8n Workflow Workflow Logic Webhook Trigger ↓ Receive ESP32 Data ↓ Check Power Threshold ↓ IF High Usage? ↙ ↘ YES NO ↓ ↓ Telegram Store Data Voice Alert Google Sheets 12. Telegram Bot Setup Steps Open Telegram Search BotFather Create bot using: /newbot Copy Bot Token Use token in n8n Telegram node 13. Voice Alert Message Example: ⚠ Warning! High electricity consumption detected. Current power usage is 1200 Watts. Please check connected appliances. 14. ThingSpeak Dashboard Fields Field Data Field 1 Voltage Field 2 Current Field 3 Power Graphs: Real-time power graph Daily consumption Peak usage trends 15. Google Sheets Integration Data stored automatically: Time Voltage Current Power 10:00 230 0.5 115 10:05 231 0.7 161 16. AI Prediction Module Prediction uses: Historical averages Peak-hour analysis Trend calculation Simple prediction formula: Prediction= 2 Previous Usage+Current Usage ​ Advanced versions can use: Linear Regression TensorFlow Lite TinyML on ESP32 17. Automation Scenarios Scenario 1 High power usage: Send Telegram alert Activate relay cutoff Scenario 2 Low power factor: Notify maintenance team Scenario 3 Abnormal spike: Store emergency event 18. Advantages Low-cost smart meter Remote monitoring Cloud-based analytics AI-enabled predictions Automation-ready Energy-saving system 19. Applications Smart homes Industries Energy management Hostels Offices Solar monitoring systems 20. Future Enhancements Mobile app MQTT communication Firebase integration Voice assistant support TinyML forecasting Solar energy optimization Multi-room monitoring 21. Conclusion This project demonstrates a modern AI-powered Agentic IoT energy monitoring system using ESP32, cloud computing, AI prediction, and workflow automation. By integrating: ESP32 n8n Telegram alerts Google Sheets ThingSpeak AI analytics the system becomes a scalable smart energy solution suitable for future smart cities and Industry 4.0 applications.