Saturday, 30 May 2026

AI Smart Road Pothole Detection and Mapping System

AI Smart Road Pothole Detection and Mapping System AI-Powered ESP32 + Agentic IoT + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard
AI Smart Road Pothole Detection and Mapping System AI-Powered ESP32 + Agentic IoT + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard 1. Project Overview Project Title AI Smart Road Pothole Detection and Mapping System using ESP32, Agentic IoT, n8n Automation, Telegram Voice Alerts, Google Sheets, and ThingSpeak Cloud Dashboard Objective The objective of this project is to: Detect road potholes automatically using sensors connected to ESP32. Collect pothole location data using GPS. Send real-time data to cloud platforms. Store pothole records in Google Sheets. Display pothole statistics on ThingSpeak Dashboard. Trigger AI-based notifications through Telegram. Generate voice alerts using AI automation. Predict power consumption and battery health using AI logic. Create a scalable smart-city road monitoring solution. 2. System Architecture Road Pothole │ ▼ MPU6050 Accelerometer │ ▼ ESP32 │ ├────────► ThingSpeak Dashboard │ ├────────► n8n Webhook │ │ │ ▼ │ AI Decision Agent │ │ │ ┌────────┼─────────┐ │ ▼ ▼ │ Google Sheets Telegram Bot │ │ │ ▼ │ Voice Notification │ ▼ GPS Location Data 3. Working Principle The accelerometer continuously monitors road vibrations. When: Acceleration > Threshold The system identifies a pothole event. ESP32 then: Reads GPS coordinates. Measures vibration intensity. Calculates pothole severity. Uploads data to: ThingSpeak n8n Webhook n8n performs: AI classification Data logging Voice generation Telegram notification Google Sheet storage 4. Components List Component Quantity ESP32 Dev Board 1 MPU6050 Accelerometer & Gyroscope 1 NEO-6M GPS Module 1 SIM800L GSM Module (Optional) 1 Buzzer 1 LED Indicator 1 Li-Ion Battery 1 TP4056 Charging Module 1 Voltage Regulator 1 Jumper Wires As required Breadboard / PCB 1 5. Hardware Connections MPU6050 → ESP32 MPU6050 ESP32 VCC 3.3V GND GND SDA GPIO21 SCL GPIO22 GPS NEO-6M → ESP32 GPS ESP32 VCC 3.3V GND GND TX GPIO16 RX GPIO17 Buzzer Buzzer ESP32 + GPIO25 - GND LED LED ESP32 Anode GPIO26 Cathode GND 6. Circuit Schematic Diagram MPU6050 +----------+ | SDA SCL | +----|--|--+ | | | | GPIO21 GPIO22 ESP32 +-------------+ | | GPS TX -->| GPIO16 | GPS RX <--| GPIO17 | BUZZER -->| GPIO25 | LED ----->| GPIO26 | | | +-------------+ | | WiFi Internet | ▼ ThingSpeak + n8n 7. Flowchart START │ ▼ Initialize ESP32 │ ▼ Connect WiFi │ ▼ Read MPU6050 Data │ ▼ Acceleration > Threshold? │ ┌┴────────────┐ │ │ NO YES │ │ ▼ ▼ Continue Read GPS Monitoring │ ▼ Calculate Severity │ ▼ Send Data to Cloud │ ▼ Trigger n8n │ ▼ AI Agent Analysis │ ▼ Telegram Voice Alert │ ▼ Store Google Sheet │ ▼ END 8. Pothole Severity Classification Severity Acceleration Value Low 1.0g – 1.5g Medium 1.5g – 2.5g High > 2.5g 9. ESP32 Source Code #include #include #include #include MPU6050 mpu; const char* ssid = "YOUR_WIFI"; const char* password = "YOUR_PASSWORD"; String webhookURL = "https://your-n8n-server/webhook/pothole"; float threshold = 1.5; void setup() { Serial.begin(115200); WiFi.begin(ssid,password); while(WiFi.status()!=WL_CONNECTED) { delay(500); } Wire.begin(); mpu.initialize(); } void loop() { int16_t ax, ay, az; mpu.getAcceleration(&ax,&ay,&az); float vibration = sqrt(ax*ax+ay*ay+az*az)/16384.0; if(vibration > threshold) { sendData(vibration); } delay(1000); } void sendData(float value) { HTTPClient http; http.begin(webhookURL); http.addHeader("Content-Type", "application/json"); String payload = "{\"severity\":" + String(value) + "}"; http.POST(payload); http.end(); } 10. n8n Workflow Architecture Webhook │ ▼ AI Agent │ ├────► Google Sheets │ ├────► ThingSpeak Update │ ├────► OpenAI Analysis │ └────► Telegram Alert 11. n8n Workflow Steps Node 1: Webhook Method: POST Receive: { "severity": 2.8, "latitude": 17.3850, "longitude": 78.4867 } Node 2: AI Agent Prompt: Analyze pothole severity. If severity > 2.5 Category = Critical If severity > 1.5 Category = Medium Else Category = Low Node 3: Google Sheets Columns: Date Time Latitude Longitude Severity Category Status Node 4: Telegram Notification Message: ⚠️ Pothole Detected Location: 17.3850,78.4867 Severity: Critical Immediate inspection required. 12. Example n8n Workflow JSON { "nodes": [ { "name": "Webhook" }, { "name": "AI Agent" }, { "name": "Google Sheets" }, { "name": "Telegram" } ] } 13. Telegram Bot Setup Step 1 Open Telegram Search: @BotFather Create bot: /newbot Step 2 Copy Bot Token. Example: 123456:ABCDEF Step 3 Add token in n8n Telegram node. 14. Voice Notification Automation AI Voice Message Message generated: Warning. Critical pothole detected. Location latitude 17.3850 longitude 78.4867. Municipal inspection required. Workflow AI Agent │ ▼ Text to Speech │ ▼ MP3 File │ ▼ Telegram Send Audio 15. Google Sheets Integration Create Sheet: Pothole_Database Columns: Timestamp Latitude Longitude Severity Category Action Connect Google Account in n8n. Use: Append Row Node. 16. ThingSpeak Dashboard Setup Create channel on: ThingSpeak Fields: Field Purpose Field1 Severity Field2 Latitude Field3 Longitude Field4 Power Consumption Field5 Pothole Count Visualization Charts: Severity Trend GPS Heatmap Daily Pothole Count Power Usage Trend 17. AI Power Consumption Prediction Logic Inputs Battery Voltage WiFi Usage Sensor Sampling Rate GPS Activity Formula P=V×I Where: P = Power V = Voltage I = Current AI Rule Engine IF Battery < 20% Reduce Sampling Rate Disable GPS Continuous Mode Send Battery Alert Predicted States Battery Status >80% Healthy 50-80% Normal 20-50% Warning <20% Critical 18. AI Agent Decision Logic Input: Severity + Location + Historical Data AI Agent evaluates: 1. Repeated pothole? 2. High traffic area? 3. Severity level? 4. Repair priority? Priority Score Priority = (Severity × 50%) + (Traffic Density × 30%) + (Repeat Count × 20%) 19. ThingSpeak Data Format Example: field1=2.8 field2=17.3850 field3=78.4867 field4=1.2 field5=45 HTTP Request: https://api.thingspeak.com/update?api_key=YOURKEY&field1=2.8 20. Advanced Future Enhancements Computer Vision Pothole Detection Add: ESP32-CAM Edge AI Models: YOLOv8 Nano MobileNet SSD GIS Mapping Integrate: OpenStreetMap Google Maps API Display: Pothole clusters Maintenance zones Smart City Dashboard Features: Heatmaps AI Analytics Municipal Alerts Maintenance Scheduling Predictive Maintenance Use: Historical pothole data Rainfall data Traffic data Predict: Road Failure Probability before pothole formation. 21. Deployment Guide Phase 1: Prototype ESP32 MPU6050 GPS WiFi Phase 2: Pilot Install on: Municipal vehicles Buses Garbage trucks Phase 3: Smart City Scale Deploy: 100+ Nodes Central Cloud Dashboard AI Maintenance Management 22. Expected Outputs ✅ Real-time pothole detection ✅ GPS-based pothole mapping ✅ AI severity classification ✅ Telegram text alerts ✅ Telegram voice alerts ✅ Google Sheets logging ✅ ThingSpeak cloud visualization ✅ AI power management ✅ Smart-city ready deployment ✅ Fully scalable Agentic IoT architecture This architecture is suitable for final-year engineering projects, smart-city research, municipal road monitoring, and AIoT deployments with ESP32, n8n, Telegram automation, Google Sheets, and cloud analytics.

No comments:

Post a Comment

AI Smart Solar Panel Tracking System with Weather Optimization

AI Smart Solar Panel Tracking System with Weather Optimization ESP32 + AI Agent + n8n Automation + Telegram Voice Alerts + Google Sheets + T...