Thursday, 28 May 2026

AI-Powered Driver Drowsiness Detection and Accident Prevention System

๐Ÿš— AI-Powered Driver Drowsiness Detection & Accident Prevention System (ESP32 + IoT + n8n + Telegram + Google Sheets + ThingSpeak + AI Agentic Workflow)
Below is a complete, structured, step-by-step documentation for your project: ๐Ÿš— AI-Powered Driver Drowsiness Detection & Accident Prevention System (ESP32 + IoT + n8n + Telegram + Google Sheets + ThingSpeak + AI Agentic Workflow) 1. ๐Ÿ“Œ Project Overview This system detects driver drowsiness in real time using AI and sensors and triggers instant multi-channel alerts using: ๐Ÿ“ฑ Telegram (text + voice alerts) ๐Ÿ“Š Google Sheets (logging) ☁️ ThingSpeak (IoT dashboard) ๐Ÿ”„ n8n automation workflows (AI agentic orchestration) ๐Ÿค– ESP32 microcontroller (edge device) ๐ŸŽฏ Goal: Prevent road accidents by detecting: Eye closure (PERCLOS method or IR sensor) Head tilt / nodding Sudden inactivity / fatigue patterns 2. ๐Ÿงฐ Components List Hardware ESP32 Dev Board IR Eye Blink Sensor / Camera module (OV2640 optional) MPU6050 (Accelerometer + Gyroscope) Buzzer (Alarm) Vibration motor (optional) OLED Display (optional) Power bank / 5V supply Software / Cloud n8n Automation Server (self-hosted or cloud) Telegram Bot API Google Sheets API ThingSpeak IoT Cloud Python (optional AI processing) Arduino IDE / PlatformIO 3. ⚡ System Architecture Sensors (Eye + Head movement) ↓ ESP32 (Edge Processing) ↓ WiFi n8n Webhook Trigger ↓ ┌───────────────┬────────────────┬─────────────────┐ │ Telegram Bot │ Google Sheets │ ThingSpeak │ │ Voice Alerts │ Data Logging │ Dashboard │ └───────────────┴────────────────┴─────────────────┘ ↓ AI Agent (n8n / Python) ↓ Risk Score + Alert Decision 4. ๐Ÿ”„ Flowchart (System Logic) START ↓ Read Eye Blink + Head Movement ↓ Compute Drowsiness Score ↓ Is Score > Threshold? ├── NO → Continue Monitoring └── YES → ↓ Trigger ESP32 Alarm ↓ Send data to n8n webhook ↓ AI Agent evaluates risk ↓ Send: → Telegram message + voice alert → Google Sheets log entry → ThingSpeak update END LOOP 5. ๐Ÿ”Œ Circuit Schematic (Connections) ESP32 Pin Mapping IR Eye Sensor VCC → 3.3V GND → GND OUT → GPIO 34 MPU6050 VCC → 3.3V GND → GND SDA → GPIO 21 SCL → GPIO 22 Buzzer → GPIO 25 → GND Vibration Motor (optional) GPIO 26 → transistor → motor 6. ๐Ÿ’ป ESP32 Source Code (Arduino) #include #include #include #define EYE_SENSOR 34 #define BUZZER 25 const char* ssid = "YOUR_WIFI"; const char* password = "YOUR_PASS"; String n8n_url = "https://your-n8n-webhook-url"; void setup() { Serial.begin(115200); pinMode(EYE_SENSOR, INPUT); pinMode(BUZZER, OUTPUT); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); } } void loop() { int eyeValue = analogRead(EYE_SENSOR); Serial.println(eyeValue); if (eyeValue < 1000) { // drowsy threshold example digitalWrite(BUZZER, HIGH); sendToN8N(eyeValue); } else { digitalWrite(BUZZER, LOW); } delay(500); } void sendToN8N(int value) { if (WiFi.status() == WL_CONNECTED) { HTTPClient http; http.begin(n8n_url); http.addHeader("Content-Type", "application/json"); String payload = "{\"eye_status\":" + String(value) + "}"; http.POST(payload); http.end(); } } 7. ๐Ÿ”„ n8n Workflow (JSON) Workflow Steps: Webhook trigger AI Function node Telegram node Google Sheets node HTTP request to ThingSpeak { "nodes": [ { "name": "Webhook", "type": "n8n-nodes-base.webhook" }, { "name": "AI Risk Analyzer", "type": "n8n-nodes-base.function", "parameters": { "functionCode": "const val = $json.eye_status;\nreturn [{ risk: val < 1000 ? 'HIGH' : 'LOW' }];" } } ] } (Full n8n workflows can be extended with drag-and-drop UI) 8. ๐Ÿค– Telegram Bot Setup Step 1: Create Bot Open Telegram → search: BotFather Send: /newbot Get API token Step 2: Get Chat ID Search: @userinfobot Copy chat ID Step 3: n8n Telegram Node Bot Token → paste API key Chat ID → your ID Message Example: ๐Ÿšจ Drowsiness Alert! Driver fatigue detected. Immediate attention required. 9. ๐Ÿ“Š Google Sheets Integration Steps: Open Google Sheets Create columns: Time | Eye Value | Risk Level | Action In Google Cloud: Enable Google Sheets API Create Service Account Share sheet with service email In n8n: Add “Google Sheets Node” Append row on trigger 10. ☁️ ThingSpeak Setup Step 1: Create channel: Field1 → Eye value Field2 → Risk level Step 2: API Key from: Channel → API Keys ESP32 / n8n send: https://api.thingspeak.com/update?api_key=XXXX&field1=value 11. ๐Ÿง  AI Drowsiness Detection Logic Method 1 (Simple Threshold) Eye sensor value < threshold → drowsy Method 2 (Better AI Model) Train ML model using: Eye blink rate Eye closure duration Head tilt angle Example Model: Logistic Regression Random Forest Lightweight TensorFlow Lite (ESP32-compatible) 12. ๐Ÿ”Š Voice Notification System Method: Use Telegram voice message or TTS API Option A (n8n + TTS API) Convert text → speech file Send as audio in Telegram Option B: Telegram voice message node 13. ⚙️ Automation Logic (n8n AI Agent Style) IF risk = HIGH: → Send Telegram alert → Trigger buzzer via ESP32 webhook → Log to Google Sheets → Update ThingSpeak → Send voice alert ELSE: → Only log data 14. ๐Ÿš€ Future Enhancements Advanced AI: CNN-based eye detection (camera module) Real-time face landmark detection (MediaPipe) Vehicle Integration: CAN bus integration Automatic braking system trigger Cloud AI: AWS IoT Core integration Azure Digital Twin model Smart Features: Driver identity recognition Fatigue prediction over time Accident prediction model 15. ๐Ÿ“ฆ Deployment Guide Step 1 Upload ESP32 code Step 2 Deploy n8n server (Docker recommended) Step 3 Connect Telegram bot Step 4 Enable Google Sheets API Step 5 Create ThingSpeak dashboard Step 6 Test full pipeline: Simulate eye closure Check alerts flow 16. ๐Ÿงช Testing Checklist ESP32 connects to WiFi ✔ Eye sensor reading changes ✔ Buzzer triggers ✔ n8n receives webhook ✔ Telegram alert sent ✔ Google Sheets logs ✔ ThingSpeak updates ✔ 17. ๐Ÿ“Š Final System Summary Feature Technology Edge device ESP32 Detection IR / ML / MPU6050 Automation n8n Messaging Telegram Bot Data logging Google Sheets Cloud IoT ThingSpeak AI logic Rule-based / ML If you want, I can also next provide: ✅ 1. ๐Ÿงฉ Full Circuit Diagram (Text + Image Description) ๐Ÿ”Œ Final Hardware Architecture ┌────────────────────┐ │ ESP32 DevKit │ └─────────┬──────────┘ │ ┌────────────────────┼────────────────────┐ │ │ │ ┌────▼────┐ ┌──────▼──────┐ ┌─────▼─────┐ │ IR Eye │ │ MPU6050 │ │ Buzzer │ │ Sensor │ │ Gyro+Accel │ │ Alert │ └────┬────┘ └──────┬──────┘ └─────┬─────┘ │ │ │ GPIO34 GPIO21/22 GPIO25 WiFi (Internet) │ ▼ ┌──────────────────────────┐ │ n8n Server │ └─────────┬────────────────┘ │ ┌──────────────┼───────────────┐ ▼ ▼ ▼ Telegram Bot Google Sheets ThingSpeak (Alert + Voice) Logging Dashboard ๐Ÿ–ผ️ If you want real diagram image: I can generate a clean PNG/SVG circuit diagram (professional Fritzing style). Just say: ๐Ÿ‘‰ “Make PCB-style diagram” ✅ 2. ๐Ÿ”„ n8n Workflow (READY IMPORT JSON) Save this as: drowsiness_n8n_workflow.json ๐Ÿ“ฅ FULL IMPORTABLE WORKFLOW { "name": "Driver Drowsiness Detection System", "nodes": [ { "parameters": { "path": "drowsiness", "method": "POST" }, "name": "Webhook", "type": "n8n-nodes-base.webhook", "typeVersion": 1, "position": [250, 300] }, { "parameters": { "functionCode": "const eye = $json.eye_status;\nconst risk = eye < 1000 ? 'HIGH' : 'LOW';\nreturn [{ eye, risk }];" }, "name": "AI Risk Engine", "type": "n8n-nodes-base.function", "typeVersion": 1, "position": [500, 300] }, { "parameters": { "chatId": "YOUR_CHAT_ID", "text": "๐Ÿšจ Drowsiness Alert!\nRisk Level: {{$json.risk}}\nEye Value: {{$json.eye}}" }, "name": "Telegram Alert", "type": "n8n-nodes-base.telegram", "typeVersion": 1, "position": [750, 200] }, { "parameters": { "operation": "append", "sheetId": "YOUR_SHEET_ID", "range": "Sheet1!A:D", "data": "={{[$now, $json.eye, $json.risk, 'Alert Sent']}}" }, "name": "Google Sheets Logger", "type": "n8n-nodes-base.googleSheets", "typeVersion": 1, "position": [750, 400] }, { "parameters": { "url": "https://api.thingspeak.com/update", "method": "GET", "queryParametersUi": { "parameter": [ { "name": "api_key", "value": "YOUR_API_KEY" }, { "name": "field1", "value": "={{$json.eye}}" } ] } }, "name": "ThingSpeak Update", "type": "n8n-nodes-base.httpRequest", "typeVersion": 1, "position": [1000, 300] } ], "connections": { "Webhook": { "main": [[{"node": "AI Risk Engine", "type": "main", "index": 0}]] }, "AI Risk Engine": { "main": [ [{"node": "Telegram Alert", "type": "main", "index": 0}], [{"node": "Google Sheets Logger", "type": "main", "index": 0}], [{"node": "ThingSpeak Update", "type": "main", "index": 0}] ] } } } ✅ 3. ๐Ÿง  Advanced ML Model (Python + Dataset) ๐Ÿ“Š Dataset Structure driver_data.csv eye_closure blink_rate head_tilt drowsy 0.2 18 5 0 0.8 5 25 1 ๐Ÿค– Training Model (Random Forest) import pandas as pd from sklearn.model_selection import train_test_split from sklearn.ensemble import RandomForestClassifier import joblib # Load dataset data = pd.read_csv("driver_data.csv") X = data[['eye_closure', 'blink_rate', 'head_tilt']] y = data['drowsy'] X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2) model = RandomForestClassifier(n_estimators=100) model.fit(X_train, y_train) accuracy = model.score(X_test, y_test) print("Accuracy:", accuracy) joblib.dump(model, "drowsiness_model.pkl") ๐Ÿ”ฎ Real-time Prediction (ESP32 backend or server) import joblib import numpy as np model = joblib.load("drowsiness_model.pkl") def predict(eye, blink, tilt): data = np.array([[eye, blink, tilt]]) result = model.predict(data) return "DROWSY" if result[0] == 1 else "NORMAL" ✅ 4. ๐Ÿ“ฑ Mobile Dashboard (Flutter Alternative) ๐Ÿš€ Option A: Flutter App Features: Live drowsiness status Graph (ThingSpeak API) Alert history Driver score ๐Ÿ“ฑ Flutter UI Code (Basic) import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( home: Dashboard(), ); } } class Dashboard extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text("Driver Monitor")), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text("Drowsiness Status: NORMAL", style: TextStyle(fontSize: 20)), SizedBox(height: 20), ElevatedButton( onPressed: () {}, child: Text("Refresh Data"), ) ], ), ), ); } } ๐Ÿš€ Option B: No-Code Dashboard (Recommended) Use: Blynk IoT ThingSpeak IoT Platform Features: Drag-drop widgets Live graph Mobile alerts Easy ESP32 integration ✅ 5. ๐Ÿ—‚️ GitHub-Ready Project Structure driver-drowsiness-ai-iot/ │ ├── esp32/ │ ├── drowsiness.ino │ ├── n8n-workflow/ │ ├── drowsiness_n8n_workflow.json │ ├── ml-model/ │ ├── train_model.py │ ├── predict.py │ ├── driver_data.csv │ ├── drowsiness_model.pkl │ ├── flutter-app/ │ ├── lib/ │ │ ├── main.dart │ ├── docs/ │ ├── circuit_diagram.png │ ├── system_architecture.png │ ├── flowchart.png │ ├── cloud-setup/ │ ├── thingspeak_guide.md │ ├── telegram_setup.md │ ├── google_sheets_setup.md │ ├── README.md └── LICENSE ๐Ÿ“„ README.md (Sample) # AI Driver Drowsiness Detection System Tech Stack: - ESP32 - n8n Automation - Telegram Bot - ThingSpeak IoT - Google Sheets - Machine Learning (Random Forest) Features: - Real-time drowsiness detection - AI-powered risk prediction - Multi-channel alerts - Cloud dashboard monitoring Setup: 1. Upload ESP32 code 2. Import n8n workflow 3. Configure Telegram bot 4. Connect Google Sheets 5. Enable ThingSpeak channel

AI-Based Women Safety Device with Voice Recognition and Emergency Alerts

AI-Based Women Safety Device with Voice Recognition & Emergency Alerts ESP32 + Agentic IoT + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak + AI Prediction
AI-Based Women Safety Device with Voice Recognition & Emergency Alerts ESP32 + Agentic IoT + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak + AI Prediction This project is a smart women safety wearable/device built using: ESP32 Voice trigger / panic detection GPS location tracking AI-powered risk & battery prediction Emergency automation using: n8n Telegram Bot API Google Sheets ThingSpeak IoT Cloud The system can: Detect emergency situations Trigger SOS alerts Send GPS coordinates Generate voice alerts on Telegram Store incident history in Google Sheets Display live data in ThingSpeak dashboard Predict battery usage using AI logic Enable future AI-agent based decision making 1. PROJECT OVERVIEW Objective Develop an intelligent women safety system capable of: Emergency detection Voice-triggered activation Real-time cloud monitoring Automated alerting AI-based predictive analytics 2. SYSTEM ARCHITECTURE Overall Workflow User in danger ↓ Voice trigger / Panic button pressed ↓ ESP32 collects: - GPS location - Device status - Audio trigger - Battery level ↓ ESP32 sends data to: - n8n webhook - ThingSpeak cloud ↓ n8n automation: - Sends Telegram alert - Converts text to voice - Logs to Google Sheets - Triggers AI workflow ↓ Emergency contacts receive: - Message - Live location - Voice alert 3. COMPONENTS LIST Component Quantity Purpose ESP32 Dev Board 1 Main controller GPS Module NEO-6M 1 Location tracking Microphone Sensor (MAX9814 / KY-038) 1 Voice detection Push Button 1 Panic switch Buzzer 1 Alarm indication OLED Display (Optional) 1 Status display Li-ion Battery 1 Portable power TP4056 Charging Module 1 Battery charging SIM800L (Optional) 1 GSM backup alerts Jumper Wires — Connections Breadboard / PCB — Prototype 4. CIRCUIT SCHEMATIC CONNECTIONS ESP32 Pin Connections Module ESP32 Pin GPS TX GPIO16 (RX2) GPS RX GPIO17 (TX2) Panic Button GPIO4 Buzzer GPIO5 Microphone OUT GPIO34 Battery Voltage GPIO35 OLED SDA GPIO21 OLED SCL GPIO22 5. CIRCUIT WORKING Step-by-Step 1. ESP32 Initialization WiFi connection established Sensors initialized Telegram/n8n endpoints loaded 2. Monitoring State ESP32 continuously checks: Panic button Voice trigger Battery level 3. Emergency Trigger If: Panic button pressed OR Voice keyword detected ("HELP", "SAVE ME") then: GPS fetched Alarm activated Cloud notification sent 4. n8n Workflow Executes n8n: Receives webhook data Sends Telegram alert Generates voice message Logs incident Stores AI analytics 6. FLOWCHART START ↓ Initialize ESP32 ↓ Connect WiFi ↓ Read Sensors ↓ Emergency Detected? ┌─────────────┐ │ NO │ │ Continue │ └─────┬───────┘ ↓ YES ↓ Get GPS Location ↓ Send Data to n8n ↓ n8n Sends: - Telegram Alert - Voice Message - Google Sheets Log ↓ Update ThingSpeak ↓ Activate Buzzer ↓ END 7. ESP32 SOURCE CODE Required Libraries Install from Arduino IDE: WiFi.h HTTPClient.h TinyGPS++ ArduinoJson ESP32 Arduino Code #include #include const char* ssid = "YOUR_WIFI"; const char* password = "YOUR_PASSWORD"; String webhook = "YOUR_N8N_WEBHOOK"; #define BUTTON_PIN 4 #define BUZZER_PIN 5 void setup() { Serial.begin(115200); pinMode(BUTTON_PIN, INPUT_PULLUP); pinMode(BUZZER_PIN, OUTPUT); WiFi.begin(ssid, password); while(WiFi.status() != WL_CONNECTED){ delay(500); Serial.print("."); } Serial.println("WiFi Connected"); } void loop() { if(digitalRead(BUTTON_PIN)==LOW){ digitalWrite(BUZZER_PIN, HIGH); if(WiFi.status()==WL_CONNECTED){ HTTPClient http; http.begin(webhook); http.addHeader("Content-Type","application/json"); String jsonData = R"({ "status":"EMERGENCY", "latitude":"17.3850", "longitude":"78.4867", "battery":"78" })"; int response = http.POST(jsonData); Serial.println(response); http.end(); } delay(5000); digitalWrite(BUZZER_PIN, LOW); } } 8. n8n AUTOMATION WORKFLOW n8n Workflow Overview Webhook Trigger ↓ Parse JSON ↓ Telegram Message ↓ Text-to-Speech ↓ Telegram Voice Alert ↓ Google Sheets Entry ↓ ThingSpeak Update 9. 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" } ] } 10. TELEGRAM BOT SETUP Step 1: Open Telegram Search: Telegram Step 2: Open BotFather Search: BotFather Step 3: Create Bot Command: /newbot Provide: Bot Name Username You receive: BOT TOKEN Save this token. Step 4: Get Chat ID Open: https://api.telegram.org/botTOKEN/getUpdates Send message to bot. Find: chat:{ "id":123456 } 11. TELEGRAM ALERT MESSAGE FORMAT Text Alert ๐Ÿšจ WOMEN SAFETY ALERT ๐Ÿšจ Emergency Detected! Location: https://maps.google.com/?q=LAT,LON Battery: 78% Immediate assistance required. 12. TELEGRAM VOICE ALERT AUTOMATION Workflow Emergency Text ↓ Google TTS API ↓ MP3 Voice ↓ Telegram Voice Message Voice Message Example Emergency detected. Please help immediately. Location has been shared. 13. GOOGLE SHEETS INTEGRATION Create Google Sheet Example columns: Timestamp Latitude Longitude Battery Status Connect Google Sheets to n8n Steps Create Google Cloud Project Enable Google Sheets API Create OAuth Credentials Add credentials in n8n Select spreadsheet 14. THINGSPEAK CLOUD DASHBOARD SETUP Create Account Open: ThingSpeak Dashboard Create Channel Fields: Emergency Status Battery % Latitude Longitude API Write URL https://api.thingspeak.com/update?api_key=KEY 15. AI POWER CONSUMPTION PREDICTION Objective Predict: Remaining battery life Device active duration Alert frequency Parameters Used Parameter Description WiFi Usage Current draw GPS Usage Tracking load Alerts Sent Communication usage Battery Voltage Power status AI Logic Simple prediction: Battery Remaining = Current Battery - (Average Hourly Consumption × Time) Future AI Enhancement Use: TinyML TensorFlow Lite Edge AI for: Behavior prediction Threat pattern detection Voice emotion analysis 16. VOICE RECOGNITION SYSTEM Basic Method ESP32 microphone listens for: "HELP" "SAVE ME" "EMERGENCY" Advanced AI Method Use: Edge Impulse TinyML Keyword Spotting Platforms: Edge Impulse TensorFlow Lite for Microcontrollers 17. THINGSPEAK DATA VISUALIZATION Dashboard Charts: Battery graph Emergency count GPS mapping Alert timeline 18. AI AGENTIC AUTOMATION IDEAS AI Agent Can: Auto-call nearest police Detect repeated danger zones Analyze user movement Predict unsafe areas 19. SECURITY FEATURES Feature Description HTTPS Secure communication API Tokens Authentication GPS Encryption Privacy Backup Alerts GSM redundancy 20. FUTURE ENHANCEMENTS Hardware Smartwatch integration Hidden wearable design Solar charging AI Emotion recognition Violence sound detection Real-time AI assistant Cloud Firebase integration AWS IoT Real-time dashboards 21. DEPLOYMENT GUIDE Prototype Stage Breadboard testing Serial monitor debugging PCB Design Use: KiCad EasyEDA Mobile Integration Android app Flutter dashboard 22. TESTING PROCEDURE Test Cases Test Expected Result Panic button Telegram alert Voice trigger Emergency activated Internet lost GSM backup Low battery Warning alert 23. PROJECT FOLDER STRUCTURE WomenSafetyAI/ │ ├── ESP32_Code/ ├── n8n_Workflow/ ├── TelegramBot/ ├── GoogleSheets/ ├── ThingSpeak/ ├── AI_Model/ ├── Documentation/ └── CircuitDiagram/ 24. COMPLETE DATA FLOW ESP32 ↓ WiFi ↓ n8n Webhook ↓ Telegram + Google Sheets + ThingSpeak ↓ Emergency Contacts 25. ADVANCED FEATURES YOU CAN ADD AI Features Face recognition Danger sound classification Automatic distress detection IoT Features Live GPS tracking Geofencing Cloud analytics Smart Automation Auto siren activation Nearby hospital notification Emergency call automation 26. REAL-WORLD APPLICATIONS Women safety wearable Child safety tracking Elderly emergency system Smart security device 27. FINAL OUTPUT OF SYSTEM When emergency occurs: ✅ Buzzer activates ✅ GPS captured ✅ Telegram text sent ✅ Voice alert sent ✅ Google Sheets updated ✅ ThingSpeak dashboard updated ✅ AI prediction generated 28. RECOMMENDED SOFTWARE TOOLS Tool Purpose Arduino IDE ESP32 programming n8n Automation Workflow automation ThingSpeak IoT cloud Google Cloud Console API management EasyEDA PCB design 29. ESTIMATED PROJECT COST Item Approx Cost Total:8000/- This project combines: AI IoT Cloud Automation Edge Computing Real-Time Emergency Response to create a powerful intelligent women safety system using: ESP32 n8n Telegram ThingSpeak Google Sheets This can be developed into: Wearable safety band Smart pendant Smart mobile assistant AI-enabled emergency ecosystem

AI-Based Voice Controlled Industrial Automation System

AI-Based Voice Controlled Industrial Automation System ESP32 + AI Agent + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard
AI-Based Voice Controlled Industrial Automation System ESP32 + AI Agent + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard This project combines: Industrial automation using ESP32 Voice-controlled operation AI-based monitoring and prediction IoT cloud dashboard n8n workflow automation Telegram voice alert notifications Google Sheets data logging ThingSpeak live monitoring The system can: Monitor industrial parameters (temperature, gas, vibration, current, voltage) Control machines using voice commands Predict abnormal power usage Send voice alerts to Telegram Store data in Google Sheets Display live analytics on ThingSpeak Trigger AI-based automation actions 1. Project Overview Main Features ✅ Voice-controlled industrial equipment ✅ AI-powered power consumption prediction ✅ Real-time sensor monitoring ✅ ESP32 WiFi-based automation ✅ Telegram voice notification alerts ✅ Google Sheets logging ✅ ThingSpeak cloud analytics ✅ n8n automation workflows ✅ Remote monitoring dashboard ✅ Agentic AI decision making 2. System Architecture +----------------------+ | Voice Commands | | (Telegram / Web UI) | +----------+-----------+ | v +---------------------------------------------------+ | n8n Server | |---------------------------------------------------| | AI Agent Logic | | Telegram Bot | | Google Sheets Integration | | Voice Alert Generator | | Webhook Automation | +-------------------+-------------------------------+ | v +-------------------+ | ESP32 | |-------------------| | WiFi Connectivity | | Relay Control | | Sensor Monitoring | +---------+---------+ | v +----------------------------+ | Industrial Devices/Sensors | +----------------------------+ | v +----------------+ | ThingSpeak IoT | +----------------+ 3. Components Required Component Quantity Purpose ESP32 Dev Board 1 Main controller Relay Module (4-channel) 1 Machine control DHT22 Sensor 1 Temperature/Humidity ACS712 Current Sensor 1 Power monitoring MQ-2 Gas Sensor 1 Gas detection Vibration Sensor 1 Machine vibration OLED Display (Optional) 1 Local display Buzzer 1 Alarm Power Supply 5V/12V 1 System power Jumper Wires Several Connections Breadboard/PCB 1 Assembly WiFi Router 1 Internet connectivity 4. Circuit Schematic Diagram ESP32 Pin Connections Sensor/Module ESP32 Pin Relay IN1 GPIO 26 Relay IN2 GPIO 27 DHT22 Data GPIO 4 MQ2 Analog GPIO 34 ACS712 Output GPIO 35 Vibration Sensor GPIO 32 Buzzer GPIO 25 5. Working Principle Step-by-Step Process Step 1 — Sensor Data Collection ESP32 continuously reads: Temperature Humidity Current usage Gas leakage Vibration status Step 2 — WiFi Communication ESP32 sends sensor data to: ThingSpeak n8n webhook Google Sheets Step 3 — AI Analysis AI agent inside n8n: Predicts abnormal power consumption Detects machine anomalies Identifies unsafe conditions Step 4 — Automation Actions If abnormality detected: Relay OFF command Telegram alert sent Voice message generated Data stored in cloud Step 5 — Dashboard Monitoring User can monitor: Real-time charts Machine health Power usage Alerts history 6. Flowchart START | v Initialize ESP32 | Connect WiFi | Read Sensors | Send Data to n8n | Send Data to ThingSpeak | AI Analysis | Abnormal? / \ YES NO | | Send Alert | | Turn OFF Relay | | Telegram Voice Alert | Store Data in Google Sheets | Repeat Loop 7. ESP32 Source Code #include #include #include "DHT.h" #define DHTPIN 4 #define DHTTYPE DHT22 #define RELAY_PIN 26 #define MQ2_PIN 34 #define CURRENT_PIN 35 #define VIBRATION_PIN 32 #define BUZZER_PIN 25 DHT dht(DHTPIN, DHTTYPE); const char* ssid = "YOUR_WIFI_NAME"; const char* password = "YOUR_WIFI_PASSWORD"; String webhookURL = "YOUR_N8N_WEBHOOK_URL"; void setup() { Serial.begin(115200); pinMode(RELAY_PIN, OUTPUT); pinMode(BUZZER_PIN, OUTPUT); dht.begin(); WiFi.begin(ssid, password); while(WiFi.status() != WL_CONNECTED){ delay(1000); Serial.println("Connecting..."); } Serial.println("WiFi Connected"); } void loop() { float temp = dht.readTemperature(); float hum = dht.readHumidity(); int gas = analogRead(MQ2_PIN); int current = analogRead(CURRENT_PIN); int vibration = digitalRead(VIBRATION_PIN); Serial.println(temp); if(WiFi.status() == WL_CONNECTED){ HTTPClient http; http.begin(webhookURL); http.addHeader("Content-Type", "application/json"); String jsonData = "{"; jsonData += "\"temperature\":" + String(temp) + ","; jsonData += "\"humidity\":" + String(hum) + ","; jsonData += "\"gas\":" + String(gas) + ","; jsonData += "\"current\":" + String(current) + ","; jsonData += "\"vibration\":" + String(vibration); jsonData += "}"; int response = http.POST(jsonData); Serial.println(response); http.end(); } if(gas > 2500){ digitalWrite(RELAY_PIN, LOW); digitalWrite(BUZZER_PIN, HIGH); } else{ digitalWrite(RELAY_PIN, HIGH); digitalWrite(BUZZER_PIN, LOW); } delay(10000); } 8. Setting Up Arduino IDE Install Libraries Install: WiFi HTTPClient DHT sensor library Add ESP32 Board Open: File → Preferences Add board URL: https://dl.espressif.com/dl/package_esp32_index.json Install: ESP32 by Espressif Systems 9. n8n Automation Workflow Workflow Modules Nodes Used Node Purpose Webhook Receive ESP32 data IF Node Condition checking OpenAI/AI Agent Prediction Telegram Node Alert sending Google Sheets Data logging HTTP Node ThingSpeak update 10. Sample n8n Workflow JSON { "nodes": [ { "name": "Webhook", "type": "n8n-nodes-base.webhook" }, { "name": "AI Analysis", "type": "n8n-nodes-base.openai" }, { "name": "Telegram", "type": "n8n-nodes-base.telegram" } ] } 11. Installing n8n Using Docker docker run -it --rm \ -p 5678:5678 \ -v ~/.n8n:/home/node/.n8n \ n8nio/n8n Open: http://localhost:5678 12. Telegram Bot Setup Step 1 — Open Telegram Search: Telegram Step 2 — Create Bot Search: @BotFather Commands: /newbot Save: Bot Token Step 3 — Get Chat ID Open: https://api.telegram.org/bot/getUpdates 13. Telegram Voice Notification Method Use: Google Text-to-Speech ElevenLabs API gTTS Python module Python Voice Generator Example from gtts import gTTS text = "Warning. Gas leakage detected in factory unit." tts = gTTS(text=text, lang='en') tts.save("alert.mp3") Send MP3 through Telegram node. 14. Google Sheets Integration Step-by-Step Create Sheet Columns: Time Temp Humidity Gas Current Enable API Open: Google Cloud Console Enable: Google Sheets API Connect in n8n Use: Google OAuth credentials 15. ThingSpeak Cloud Dashboard Setup Open: ThingSpeak Create Channel Fields: Temperature Humidity Gas Current Vibration Get API Key Copy: Write API Key ESP32 Upload URL String server = "http://api.thingspeak.com/update?api_key=YOUR_KEY"; 16. AI Power Consumption Prediction Logic AI Objective Predict: Overload Abnormal current Energy waste Equipment failure Basic AI Formula Use moving average: P avg ​ = n P 1 ​ +P 2 ​ +P 3 ​ +⋯+P n ​ ​ If: Current > Threshold Then: Send alert Turn OFF relay Advanced AI Options You can use: TensorFlow Lite Edge Impulse TinyML OpenAI API 17. Voice Command Automation Supported Commands Voice Command Action Turn ON Motor Relay ON Turn OFF Motor Relay OFF Emergency Stop Shutdown Check Temperature Send sensor value Voice Recognition Methods Option 1 Telegram voice messages → n8n → AI → ESP32 Option 2 Web dashboard microphone input Option 3 Google Assistant integration 18. AI Agent Logic Agent Decisions Condition Action High Temperature Cooling ON Gas Leakage Alarm + Relay OFF High Current Shutdown Vibration Detected Maintenance Alert 19. Cloud Dashboard Features Dashboard Includes ✅ Live sensor graphs ✅ Device status ✅ AI predictions ✅ Alert logs ✅ Power analytics ✅ Historical trends 20. Future Enhancements Upgrade Ideas AI Improvements Predictive maintenance Failure forecasting ML anomaly detection Hardware Improvements Industrial PLC integration GSM backup Solar power Software Improvements Mobile app Voice assistant Multi-user control 21. Deployment Guide Industrial Deployment Steps Step 1 Assemble PCB safely. Step 2 Use isolated relay modules. Step 3 Add fuse protection. Step 4 Use industrial-grade power supply. Step 5 Deploy cloud server. Step 6 Enable HTTPS security. Step 7 Test emergency shutdown. 22. Security Recommendations Important ✅ Use HTTPS webhooks ✅ Secure API keys ✅ Use firewall rules ✅ Enable authentication ✅ Encrypt cloud communication 23. Testing Procedure Test Cases Test Expected Result Gas leakage Relay OFF High current Alert sent Voice command Device responds WiFi disconnected Auto reconnect High temperature Cooling activated 24. Real Industrial Applications Use Cases Smart factories Chemical plants Motor monitoring Energy management Boiler automation Smart agriculture Warehouse automation 25. Final Output of the System Your completed system will provide: ✅ AI-powered industrial automation ✅ Cloud-connected ESP32 monitoring ✅ Voice-controlled operations ✅ Telegram voice emergency alerts ✅ Real-time IoT dashboard ✅ Google Sheets analytics logging ✅ Intelligent predictive maintenance ✅ Remote industrial management 26. Recommended Software Stack Software Purpose Arduino IDE ESP32 programming n8n Automation Telegram Notifications ThingSpeak Cloud dashboard Google Sheets Data storage OpenAI API AI agent Docker n8n deployment 27. Recommended Project Folder Structure Industrial_AI_IOT/ │ ├── ESP32_Code/ ├── n8n_Workflow/ ├── Dashboard/ ├── AI_Model/ ├── Documentation/ ├── Telegram_Bot/ └── GoogleSheets/ 28. Conclusion This project is a complete Industry 4.0 automation solution combining: Embedded systems Artificial intelligence IoT cloud computing Automation workflows Voice communication Predictive analytics It is suitable for: Final year projects Industrial prototypes Smart factory research IoT product development AI automation systems

AI-Based Smart Vehicle Theft Detection with Face Recognition and GPS

AI-Based Smart Vehicle Theft Detection with Face Recognition and GPS Using ESP32 + Camera + GPS + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak + AI Agentic IoT Dashboard
AI-Based Smart Vehicle Theft Detection with Face Recognition and GPS Using ESP32 + Camera + GPS + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak + AI Agentic IoT Dashboard 1. Project Overview This project is an AI-powered smart vehicle security system that detects unauthorized access using: Face Recognition GPS tracking ESP32-CAM AI automation workflows Telegram voice alerts Cloud dashboards Google Sheets logging ThingSpeak IoT analytics n8n automation workflows The system continuously monitors the vehicle. When someone enters or tries to start the vehicle: ESP32-CAM captures face image AI compares face with authorized users If unauthorized: GPS location is captured Telegram alert sent Voice notification generated Data stored in Google Sheets Event uploaded to ThingSpeak dashboard Owner can remotely monitor activity 2. System Architecture ┌─────────────────────┐ │ ESP32-CAM │ │ Face Detection AI │ └─────────┬───────────┘ │ │ WiFi ▼ ┌─────────────────────┐ │ n8n │ │ Automation Server │ └──────┬───────┬──────┘ │ │ ┌─────────────────┘ └────────────────┐ ▼ ▼ ┌─────────────────┐ ┌────────────────────┐ │ Telegram Alerts │ │ Google Sheets Log │ │ Voice Messages │ │ Theft Records │ └─────────────────┘ └────────────────────┘ │ ▼ ┌──────────────────┐ │ ThingSpeak Cloud │ │ GPS + Analytics │ └──────────────────┘ 3. Features Main Features Vehicle Theft Detection Detects unauthorized access Face Recognition Authorized face database GPS Live Tracking Sends real-time vehicle location Telegram Alerts Instant notifications Voice Alerts AI-generated voice message Cloud Dashboard Real-time monitoring using ThingSpeak Data Logging Event history in Google Sheets AI Prediction Predicts power usage trends 4. Components List Component Quantity Purpose ESP32-CAM 1 Main controller + camera OV2640 Camera 1 Face capture NEO-6M GPS Module 1 GPS tracking SIM800L GSM (Optional) 1 GSM backup Relay Module 1 Vehicle ignition lock Buzzer 1 Alarm PIR Sensor 1 Motion detection OLED Display 1 Status display Lithium Battery 1 Backup power Voltage Regulator 1 Stable power Jumper Wires — Connections Breadboard/PCB — Assembly 5. Circuit Schematic Diagram ESP32-CAM Connections Module ESP32 Pin GPS TX GPIO16 GPS RX GPIO17 PIR OUT GPIO13 Relay IN GPIO12 Buzzer GPIO15 OLED SDA GPIO14 OLED SCL GPIO2 6. Working Principle Step-by-Step Working Step 1: Vehicle Monitoring ESP32 stays in monitoring mode. Step 2: Motion Detection PIR sensor detects movement. Step 3: Face Capture ESP32-CAM captures image. Step 4: AI Face Verification Face matched with authorized database. Step 5: Unauthorized Detection If face not recognized: Alarm activated GPS fetched Alert workflow triggered Step 6: n8n Automation n8n receives webhook data. Step 7: Notifications Telegram sends: Text alert GPS location Voice alert Step 8: Cloud Logging Event stored in: Google Sheets ThingSpeak 7. Flowchart START | Initialize ESP32 | Connect WiFi | Wait for Motion | Motion Detected? | NO └──> Continue Monitoring | YES | Capture Face Image | Recognized? | YES └──> Allow Access | NO | Activate Alarm | Get GPS Location | Send Data to n8n | Telegram Alert | Store in Google Sheets | Upload to ThingSpeak | END 8. ESP32 Source Code (Arduino IDE) Required Libraries Install: WiFi.h HTTPClient.h TinyGPS++ ESP32 Camera ArduinoJson ESP32 Code #include #include #include const char* ssid = "YOUR_WIFI"; const char* password = "YOUR_PASSWORD"; String webhookURL = "https://your-n8n-webhook-url"; TinyGPSPlus gps; #define PIR_PIN 13 #define BUZZER 15 void setup() { Serial.begin(115200); pinMode(PIR_PIN, INPUT); pinMode(BUZZER, OUTPUT); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); } Serial.println("WiFi Connected"); } void loop() { int motion = digitalRead(PIR_PIN); if (motion == HIGH) { digitalWrite(BUZZER, HIGH); float lat = 17.3850; float lng = 78.4867; if(WiFi.status()== WL_CONNECTED){ HTTPClient http; http.begin(webhookURL); http.addHeader("Content-Type", "application/json"); String jsonData = "{"; jsonData += "\"alert\":\"Unauthorized Access\","; jsonData += "\"latitude\":" + String(lat) + ","; jsonData += "\"longitude\":" + String(lng); jsonData += "}"; int response = http.POST(jsonData); Serial.println(response); http.end(); } delay(10000); digitalWrite(BUZZER, LOW); } } 9. Telegram Bot Setup Step 1: Open Telegram Search: Telegram Step 2: Open BotFather Search: BotFather Step 3: Create Bot Commands: /newbot BotFather gives: Bot Token Save it securely. Step 4: Get Chat ID Open browser: https://api.telegram.org/bot/getUpdates Find: "chat":{"id":12345678} 10. n8n Automation Setup Install n8n Using Docker docker run -it --rm \ -p 5678:5678 \ -v ~/.n8n:/home/node/.n8n \ docker.n8n.io/n8nio/n8n Workflow Steps Node 1: Webhook Receives ESP32 data Node 2: IF Node Checks alert condition Node 3: Telegram Node Sends alert Node 4: Google Sheets Node Stores records Node 5: HTTP Request Uploads to ThingSpeak Node 6: Text-to-Speech Generates voice alert 11. 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" } ] } 12. Google Sheets Integration Step-by-Step Create Sheet Columns: | Time | Alert | Latitude | Longitude | Status | Connect with n8n Google Cloud Console Enable Sheets API Create OAuth Credentials Connect inside n8n 13. ThingSpeak Dashboard Setup Create Account Use: ThingSpeak Official Website Create Channel Fields: Field Data Field 1 Latitude Field 2 Longitude Field 3 Alert Status Field 4 Battery Voltage API Example https://api.thingspeak.com/update?api_key=YOUR_KEY&field1=17.3850 14. Face Recognition System Options Option 1: ESP32 Basic Face Recognition Lightweight Limited accuracy Option 2: Python AI Server Recommended Use: OpenCV FaceNet DeepFace Python Face Recognition Example from deepface import DeepFace result = DeepFace.verify( img1_path="captured.jpg", img2_path="authorized.jpg" ) print(result) 15. AI Power Consumption Prediction Logic Objective Predict: Battery drain Vehicle idle usage Theft-related abnormal consumption Parameters Parameter Description Battery Voltage Current voltage GPS Usage Tracking frequency WiFi Usage Data transmission Camera Runtime AI processing load AI Logic Simple Linear Regression: power = camera_usage*0.5 + wifi_usage*0.3 + gps_usage*0.2 16. Telegram Voice Notification Automation Process n8n receives theft event Generate TTS message Convert text to MP3 Send MP3 to Telegram Example Alert Warning! Unauthorized vehicle access detected. Current GPS location shared. 17. AI Agentic IoT Logic Agent Decision System The AI agent can: Decide theft probability Trigger emergency mode Disable ignition Notify multiple users Detect repeated attempts Sample AI Rule if unknown_face and motion_detected: trigger_theft_alert() 18. Cloud Dashboard Design Dashboard Widgets Live GPS Map Intrusion Counter Battery Analytics Face Detection Log Vehicle Status 19. Future Enhancements Advanced Features Number Plate Recognition Voice Assistant Remote Engine Lock AI Behavior Prediction Edge AI Processing Mobile App Blockchain Security Logs 4G LTE Connectivity 20. Deployment Guide Step-by-Step Deployment Hardware Assembly Connect all modules Flash ESP32 Upload firmware Configure WiFi Add credentials Setup n8n Import workflow Setup Telegram Bot Add token Connect Cloud APIs ThingSpeak Google Sheets Testing Simulate theft Vehicle Installation Hide device securely 21. Security Recommendations Important Use HTTPS Secure API Keys Encrypt Face Data Enable OTP Access Use Backup Battery 22. Testing Procedure Test Expected Result Motion Detection Camera activated Unknown Face Alert triggered GPS Tracking Coordinates updated Telegram Alert Notification received Cloud Upload Dashboard updated 23. Real-World Applications Smart Cars Bike Security Fleet Monitoring Logistics Vehicles Rental Cars School Buses 24. Software Tools Required Software Purpose Arduino IDE ESP32 programming Python AI processing n8n Automation ThingSpeak Cloud dashboard Telegram Notifications 25. Final Output of the System When theft occurs: ✅ Face captured ✅ GPS tracked ✅ Telegram alert sent ✅ Voice warning generated ✅ Google Sheet updated ✅ ThingSpeak dashboard updated ✅ AI theft analysis performed 26. Suggested Folder Structure SmartVehicleSecurity/ │ ├── ESP32_Code/ ├── AI_Server/ ├── n8n_Workflow/ ├── GoogleSheets/ ├── ThingSpeak/ ├── Documentation/ └── Images/ 27. Recommended Upgrades Hardware ESP32-S3 AI accelerator LTE module Software YOLOv8 Firebase MQTT Broker Node-RED 28. Conclusion This project combines: AI IoT Automation Cloud Computing Vehicle Security to create a modern intelligent anti-theft solution using low-cost hardware and scalable cloud services. The project is suitable for: Final year engineering projects IoT research Smart transportation systems AI security applications Startup prototypes

AI-Based Smart Attendance System Using Face Recognition

AI-Based Smart Attendance System Using Face Recognition ESP32 + AI Agentic IoT + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard
AI-Based Smart Attendance System Using Face Recognition ESP32 + AI Agentic IoT + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard This project combines: Face Recognition Attendance ESP32 IoT Controller n8n Workflow Automation Telegram Alerts + Voice Notifications Google Sheets Logging ThingSpeak Cloud Dashboard AI-based Power Consumption Prediction Agentic AI Automation Logic 1. Project Overview Objective Build an intelligent attendance system that: Detects and recognizes faces Marks attendance automatically Sends data to cloud Stores records in Google Sheets Sends Telegram notifications and voice alerts Displays analytics on ThingSpeak Predicts power usage using AI logic Uses n8n as an automation brain 2. System Architecture Complete Workflow Camera Detects Face ↓ ESP32-CAM Captures Image ↓ Face Recognition Process ↓ Attendance Verified ↓ ESP32 Sends Data to n8n Webhook ↓ n8n Automation Executes ↓ ├── Google Sheets Entry ├── Telegram Message ├── Telegram Voice Alert ├── ThingSpeak Update └── AI Analytics Processing ↓ Dashboard Monitoring 3. Hardware Components List Component Quantity Purpose ESP32-CAM Module 1 Main controller + camera FTDI Programmer 1 Upload code OLED Display (Optional) 1 Status display Buzzer 1 Audio alert Relay Module (Optional) 1 Door control LED Indicators 2 Status LEDs Push Button 1 Enrollment mode Power Supply 5V 2A 1 Power Jumper Wires Several Connections Breadboard/PCB 1 Circuit setup WiFi Router 1 Internet connection 4. Software Requirements Software Purpose Arduino IDE ESP32 programming n8n Workflow automation Telegram Bot Notifications Google Sheets API Attendance logging ThingSpeak IoT cloud dashboard Python/OpenCV Face training Edge Impulse (Optional) AI model deployment 5. ESP32-CAM Pin Configuration ESP32-CAM Important Pins Pin Function GPIO0 Flash mode GPIO2 LED GPIO12 Camera GPIO13 Camera GPIO14 Camera GPIO15 Camera GPIO16 UART GPIO4 Flash LED 6. Circuit Schematic Diagram Basic Wiring ESP32-CAM -------------------------------- 5V → Power Supply 5V GND → Ground U0R → FTDI TX U0T → FTDI RX GPIO0 → GND (while uploading) Buzzer: GPIO15 → Buzzer + LED: GPIO2 → LED + Relay: GPIO14 → Relay IN 7. Face Recognition System Face Recognition Methods Option 1 — ESP32 Built-in Face Recognition Good for: Small attendance systems 5–20 users Option 2 — Python OpenCV Server Good for: Large databases Better accuracy Recommended: Use ESP32 for image capture Use Python/OpenCV for recognition 8. Face Enrollment Process Steps User presses enrollment button ESP32 captures multiple images Images stored in server/database AI model trains face embeddings Face ID assigned 9. Attendance Logic Workflow Face Detected? ↓ YES Face Recognized? ↓ YES Already Marked Today? ↓ NO Store Attendance Send Notification Update Cloud 10. ESP32 Source Code Arduino IDE Setup Install: ESP32 Board Package Camera libraries WiFi libraries ESP32 Attendance Code #include #include const char* ssid = "YOUR_WIFI"; const char* password = "YOUR_PASSWORD"; String webhookURL = "https://your-n8n-url/webhook/attendance"; 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 recognized face String personName = "Rahul"; String timeStamp = "10:30 AM"; if(WiFi.status()== WL_CONNECTED){ HTTPClient http; http.begin(webhookURL); http.addHeader("Content-Type", "application/json"); String jsonData = "{\"name\":\"" + personName + "\",\"time\":\"" + timeStamp + "\"}"; int httpResponseCode = http.POST(jsonData); Serial.println(httpResponseCode); http.end(); } delay(10000); } 11. n8n Automation Workflow What n8n Does n8n acts as the AI automation brain. It receives attendance data and performs: Google Sheets update Telegram alert Voice notification ThingSpeak update AI prediction logic 12. n8n Workflow Architecture Webhook Trigger ↓ Data Validation ↓ Google Sheets Node ↓ Telegram Node ↓ Text-to-Speech ↓ ThingSpeak API ↓ AI Prediction Function 13. Install n8n Local Installation Using Docker: docker run -it --rm \ -p 5678:5678 \ n8nio/n8n Official Website n8n 14. Create Webhook in n8n Steps Open n8n Create new workflow Add Webhook node Method → POST Path → /attendance Copy webhook URL 15. Google Sheets Integration Create Google Sheet Columns: Name Date Time Status Setup Steps Open Google Cloud Console Enable Sheets API Create Service Account Download JSON credentials Connect credentials to n8n Official APIs Google Sheets API 16. Telegram Bot Setup Create Telegram Bot Open Telegram Search for BotFather Run: /newbot Copy API token Telegram Official Telegram Bot API 17. Telegram Alert Message Example Message ✅ Attendance Marked Name: Rahul Time: 10:30 AM Status: Present 18. Voice Notification Automation Method n8n → Google TTS → Telegram Voice Voice Message Example "Rahul attendance marked successfully." 19. ThingSpeak Dashboard Setup Create ThingSpeak Channel Fields: Field Purpose Field1 Attendance Count Field2 Power Usage Field3 Recognized Faces Field4 WiFi Strength Official Website ThingSpeak 20. Sending Data to ThingSpeak HTTP Request String url = "http://api.thingspeak.com/update?api_key=YOUR_KEY&field1=1"; 21. AI Power Consumption Prediction Goal Predict system power usage using AI logic. Parameters Parameter Description Camera usage time Active duration WiFi transmission Network activity CPU load Processing usage Flash LED usage LED activity Simple Prediction Formula P total ​ =P camera ​ +P wifi ​ +P cpu ​ +P led ​ AI Logic Example predicted_power = (camera_time * 0.5) + (wifi_packets * 0.2) + (cpu_usage * 0.1) 22. AI Agentic Features Smart AI Behaviors AI Agent Can: Detect duplicate attendance Predict abnormal activity Notify low power state Detect unauthorized access Recommend energy optimization Generate daily reports 23. Advanced Attendance Validation Anti-Spoofing Features Use: Eye blink detection Face movement analysis IR sensor validation Multi-frame recognition 24. Database Design Attendance Table ID Name Date Time Confidence 25. Security Features Recommended Security HTTPS webhook Token authentication Face encryption Local backup API rate limiting 26. n8n Workflow JSON Example { "nodes": [ { "name": "Webhook", "type": "n8n-nodes-base.webhook" }, { "name": "Google Sheets", "type": "n8n-nodes-base.googleSheets" }, { "name": "Telegram", "type": "n8n-nodes-base.telegram" } ] } 27. Deployment Guide Local Deployment Good for: College projects Labs Small offices Cloud Deployment Use: AWS Railway Render VPS Docker 28. Production Architecture ESP32 Devices ↓ Cloud API Gateway ↓ n8n Server ↓ Database Cluster ↓ AI Analytics Engine 29. Future Enhancements Advanced Features AI Features Emotion detection Mask detection Crowd analytics Face aging adaptation AI attendance prediction IoT Features RFID backup Fingerprint backup Smart lock integration Battery monitoring Offline synchronization Cloud Features Mobile app Admin dashboard Multi-school support Analytics reports 30. Testing Procedure Step-by-Step Testing Hardware Test Power ESP32 Verify camera Test WiFi API Test Trigger webhook Verify Google Sheets update Check Telegram alert AI Test Train face model Test recognition accuracy 31. Troubleshooting Guide Problem Solution Camera not detected Check power supply WiFi disconnects Improve signal Face mismatch Retrain model Telegram not sending Verify bot token Sheets update fails Check API permissions 32. Recommended Folder Structure project/ │ ├── esp32_code/ ├── face_dataset/ ├── python_ai/ ├── n8n_workflow/ ├── dashboard/ ├── docs/ └── deployment/ 33. Recommended Technology Stack Layer Technology Hardware ESP32-CAM AI Vision OpenCV Automation n8n Notifications Telegram Database Google Sheets Cloud IoT ThingSpeak Backend Flask/FastAPI 34. Complete End-to-End Workflow Person Arrives ↓ Face Captured ↓ AI Recognition ↓ Attendance Verification ↓ n8n Webhook Trigger ↓ Google Sheets Updated ↓ Telegram Alert Sent ↓ Voice Notification Sent ↓ ThingSpeak Dashboard Updated ↓ AI Analytics Generated 35. Suggested Enhancements for Final Year Projects Add These for Higher Innovation Edge AI inference Real-time analytics dashboard MQTT communication Firebase integration AI chatbot assistant Voice-controlled admin system Generative AI attendance summaries 36. Recommended Learning Resources ESP32 ESP32 Official Documentation Arduino IDE Arduino IDE OpenCV OpenCV ThingSpeak ThingSpeak Documentation 37. Final Output of System The completed system will provide: ✅ AI face recognition attendance ✅ Real-time cloud monitoring ✅ Telegram alerts ✅ Voice notifications ✅ Google Sheets logs ✅ ThingSpeak analytics ✅ AI-based energy prediction ✅ Fully automated IoT workflow ✅ Smart attendance intelligence ✅ Scalable enterprise architecture 38. Conclusion This project combines: Artificial Intelligence IoT Automation Edge Computing Cloud Analytics Workflow Automation Smart Notifications into a modern smart campus/office solution suitable for: Final year projects Research projects Smart classrooms Offices Industrial attendance systems AIoT demonstrations

AI-Based Human Following Robot with Gesture Recognition

AI-Based Human Following Robot with Gesture Recognition + Agentic IoT System
AI-Based Human Following Robot with Gesture Recognition + Agentic IoT System This project combines: Human-following robot using AI and sensors Hand gesture recognition ESP32 IoT control system AI-based automation workflows Telegram voice alerts Google Sheets cloud logging ThingSpeak dashboard monitoring n8n workflow automation AI power prediction logic 1. Project Overview The robot can: ✅ Follow a human automatically ✅ Detect hand gestures for commands ✅ Send real-time Telegram alerts ✅ Store sensor data in Google Sheets ✅ Upload live telemetry to ThingSpeak cloud ✅ Use AI logic for battery/power prediction ✅ Trigger automated workflows using n8n ✅ Generate voice notifications 2. System Architecture Camera/Sensors ↓ ESP32 Controller ↓ Motor Driver + Motors ↓ WiFi Network ↓ n8n Automation Server ↓ ├── Telegram Voice Alerts ├── Google Sheets Logging ├── ThingSpeak Dashboard └── AI Prediction Engine 3. Required Components List Main Controller Component Quantity ESP32 Dev Board 1 L298N Motor Driver 1 DC Geared Motors 2 Robot Chassis 1 Wheels 2 Castor Wheel 1 Sensors Sensor Purpose Ultrasonic Sensor HC-SR04 Distance measurement IR Sensors Obstacle detection Camera Module ESP32-CAM Gesture recognition MPU6050 Motion sensing Servo Motor Camera rotation Power Item Specification Li-ion Battery 12V Battery Holder 1 Buck Converter 5V output Cloud & Automation Service Purpose ESP32 Documentation Microcontroller platform n8n Workflow automation Telegram Bot API Notification system Google Sheets Data storage ThingSpeak IoT dashboard 4. Hardware Connections ESP32 Pin Connections ESP32 Pin Connected To GPIO 12 Motor IN1 GPIO 13 Motor IN2 GPIO 14 Motor IN3 GPIO 27 Motor IN4 GPIO 26 Trigger HC-SR04 GPIO 25 Echo HC-SR04 GPIO 33 Servo Signal GPIO 32 IR Sensor Left GPIO 35 IR Sensor Right 5. Circuit Schematic Diagram +----------------+ | ESP32 | +----------------+ | | | | | | | +---- Ultrasonic Sensor | | +-------- Servo Motor | +------------ Motor Driver +---------------- WiFi Communication Motor Driver → DC Motors Battery → ESP32 + Motor Driver 6. Working Principle Human Following The ultrasonic sensor continuously measures distance. Logic: If human detected within 50cm: Move Forward Else: Stop Gesture Recognition Using ESP32-CAM: Gesture Action Palm Open Stop Thumb Up Move Forward Left Hand Turn Left Right Hand Turn Right 7. Complete Flowchart START ↓ Initialize ESP32 ↓ Connect WiFi ↓ Read Sensors ↓ Detect Human? ↓ YES Move Robot ↓ Check Gestures ↓ Execute Commands ↓ Send Data to Cloud ↓ Trigger n8n Workflow ↓ Telegram Voice Alert ↓ Store Data in Google Sheets ↓ Repeat 8. ESP32 Source Code (Main Logic) #include #include const char* ssid = "YOUR_WIFI"; const char* password = "PASSWORD"; #define TRIG 26 #define ECHO 25 void setup() { Serial.begin(115200); pinMode(TRIG, OUTPUT); pinMode(ECHO, INPUT); WiFi.begin(ssid, password); while(WiFi.status() != WL_CONNECTED) { delay(500); Serial.println("Connecting..."); } Serial.println("WiFi Connected"); } void loop() { long duration; int distance; digitalWrite(TRIG, LOW); delayMicroseconds(2); digitalWrite(TRIG, HIGH); delayMicroseconds(10); digitalWrite(TRIG, LOW); duration = pulseIn(ECHO, HIGH); distance = duration * 0.034 / 2; Serial.println(distance); if(distance < 50) { Serial.println("Human Detected"); } sendToThingSpeak(distance); delay(1000); } void sendToThingSpeak(int distance) { if(WiFi.status()== WL_CONNECTED){ HTTPClient http; String url = "http://api.thingspeak.com/update?api_key=YOUR_API_KEY&field1=" + String(distance); http.begin(url); int httpCode = http.GET(); Serial.println(httpCode); http.end(); } } 9. Setting Up Arduino IDE Install Required Libraries WiFi.h HTTPClient.h ESP32Servo.h NewPing.h Install board support: ESP32 by Espressif Systems 10. ThingSpeak Dashboard Setup Step-by-Step Open: ThingSpeak Platform Create account Create New Channel Add fields: Distance Battery Temperature Copy: Write API Key Channel ID Add API key in ESP32 code 11. Telegram Bot Setup Create Bot Open Telegram Search: @BotFather Type: /newbot Give bot name Copy Bot Token Get Chat ID Open: https://api.telegram.org/botYOUR_BOT_TOKEN/getUpdates Find: "chat":{"id":123456789} 12. Telegram Voice Notification System Workflow ESP32 Alert ↓ n8n Receives Webhook ↓ Text-to-Speech Conversion ↓ Telegram Voice Message 13. n8n Automation Workflow Install n8n Cloud Version Open: n8n Cloud Local Installation npm install n8n -g n8n start 14. n8n Workflow Logic Webhook Trigger ↓ IF Distance < Threshold ↓ Generate Alert Message ↓ Google Sheets Entry ↓ ThingSpeak Update ↓ Telegram Voice Alert 15. Sample n8n Workflow JSON { "nodes": [ { "name": "Webhook", "type": "n8n-nodes-base.webhook" }, { "name": "Telegram", "type": "n8n-nodes-base.telegram" } ] } 16. Google Sheets Integration Steps Open: Google Sheets Create Sheet Columns: Timestamp Distance Battery Gesture Status Connect Google account inside n8n Use: "Append Row" operation 17. AI-Based Power Consumption Prediction Purpose Predict remaining battery life. Inputs Parameter Description Motor Speed RPM Distance Traveled cm Battery Voltage V Current Draw A Simple Prediction Formula P=V×I Battery percentage: Battery%= Maximum Voltage Current Voltage ​ ×100 AI Logic IF battery < 20% Send alert Reduce motor speed 18. Voice Automation Using AI Text-to-Speech APIs You can use: Service Usage Google TTS Voice generation ElevenLabs AI realistic voice Telegram Voice Voice delivery 19. Cloud Dashboard Features Real-Time Monitoring Display: Robot status Gesture detected Battery level Human distance WiFi signal Temperature 20. Advanced Enhancements Future Improvements AI Features Face recognition Object detection Emotion recognition Voice command support Robotics SLAM navigation Autonomous mapping GPS tracking Cloud Firebase integration AWS IoT MQTT broker 21. Deployment Guide Indoor Deployment Use smooth flooring Stable WiFi Proper lighting Outdoor Deployment Add: Waterproof casing GPS module Solar charging 22. Security Recommendations Important Use HTTPS APIs Secure Telegram token Enable firewall on n8n server Use encrypted WiFi 23. Testing Procedure Test Expected Result Human detection Robot follows Gesture detection Executes command WiFi disconnection Auto reconnect Low battery Alert triggered Obstacle detection Robot stops 24. Final Project Outcome After completion, your system will: ✅ Follow humans intelligently ✅ Recognize gestures ✅ Send AI voice alerts ✅ Store cloud data ✅ Provide remote monitoring ✅ Predict battery usage ✅ Support full IoT automation 25. Recommended Software Stack Software Purpose Arduino IDE ESP32 programming Python AI processing OpenCV Vision system n8n Automation Telegram Bot Alerts ThingSpeak Dashboard 26. Suggested Folder Structure Project/ │ ├── ESP32_Code/ ├── n8n_Workflow/ ├── AI_Model/ ├── Documentation/ ├── Circuit_Diagram/ ├── Telegram_Bot/ └── Cloud_Dashboard/ 27. Recommended AI Extensions Add These Later YOLO object detection MediaPipe gesture recognition TensorFlow Lite Edge AI inference 28. Conclusion This project is a complete Industry 4.0 style intelligent robotics system combining: Embedded systems Artificial Intelligence Cloud IoT Automation Robotics Real-time communication It is suitable for: Final year engineering projects Research prototypes Smart surveillance Industrial automation Smart assistant robots

AI-Based Fire and Smoke Detection with Real-Time Alerts

AI-Based Fire and Smoke Detection with Real-Time Alerts AI-Powered ESP32 + Agentic IoT + n8n Automation + Telegram Voice Alerts + Cloud Dashboard
AI-Based Fire and Smoke Detection with Real-Time Alerts AI-Powered ESP32 + Agentic IoT + n8n Automation + Telegram Voice Alerts + Cloud Dashboard 1. Project Overview This project is an intelligent IoT-based fire and smoke monitoring system using an ESP32 microcontroller, environmental sensors, cloud platforms, and AI-powered automation workflows. The system continuously monitors: Smoke concentration Temperature Flame detection Air quality When abnormal conditions are detected, the ESP32 sends data to: Telegram for instant alerts Google Sheets for logging ThingSpeak dashboard for cloud visualization n8n automation server for AI-based workflows and voice notifications The system can: Detect fire/smoke in real-time Send AI-generated voice alerts Store sensor history Predict power consumption trends Trigger smart automations Enable future AI-based emergency response systems 2. Key Features Core Features ✅ Real-time fire detection ✅ Smoke monitoring ✅ ESP32 WiFi connectivity ✅ Telegram instant alerts ✅ AI voice notifications ✅ Google Sheets logging ✅ ThingSpeak cloud dashboard ✅ n8n workflow automation ✅ Agentic IoT automation ✅ AI power consumption prediction ✅ Remote monitoring dashboard 3. System Architecture ┌──────────────────┐ │ Smoke Sensor MQ2 │ └────────┬─────────┘ │ ┌────────▼─────────┐ │ Flame Sensor │ └────────┬─────────┘ │ ┌────────▼─────────┐ │ DHT11/DHT22 │ │ Temp Sensor │ └────────┬─────────┘ │ ┌────────▼─────────┐ │ ESP32 Controller │ └────────┬─────────┘ │ WiFi ┌────────────────┼─────────────────┐ │ │ │ ▼ ▼ ▼ Telegram Bot ThingSpeak n8n Automation │ │ │ ▼ ▼ ▼ Voice Alerts Cloud Dashboard Google Sheets 4. Components List Component Quantity Purpose ESP32 Dev Board 1 Main controller MQ-2 Smoke Sensor 1 Smoke detection Flame Sensor Module 1 Fire detection DHT22 Sensor 1 Temperature monitoring Buzzer Module 1 Local alarm LED Indicator 2 Status indication Breadboard 1 Circuit assembly Jumper Wires Multiple Connections 5V Power Supply 1 Power source WiFi Router 1 Internet connection 5. Circuit Schematic Diagram ESP32 CONNECTIONS MQ2 Sensor VCC → 3.3V GND → GND AOUT → GPIO34 Flame Sensor VCC → 3.3V GND → GND DOUT → GPIO27 DHT22 VCC → 3.3V GND → GND DATA → GPIO4 Buzzer + → GPIO26 - → GND Red LED + → GPIO25 - → GND 6. Working Principle The ESP32 continuously reads data from: MQ2 smoke sensor Flame sensor DHT22 temperature sensor If: Smoke exceeds threshold Flame is detected Temperature becomes dangerous Then: Local buzzer activates Telegram alert is sent Voice notification generated Data uploaded to ThingSpeak Event logged in Google Sheets n8n AI workflow processes event 7. Flowchart START │ ▼ Initialize ESP32 │ ▼ Connect WiFi │ ▼ Read Sensor Data │ ▼ Smoke/Fire Detected? ┌────┴────┐ YES NO │ │ ▼ ▼ Activate Alarm Continue Monitoring │ ▼ Send Telegram Alert │ ▼ Trigger Voice Alert │ ▼ Upload to ThingSpeak │ ▼ Store in Google Sheets │ ▼ AI Analysis via n8n │ ▼ LOOP 8. ESP32 Source Code (Arduino IDE) #include #include #include "DHT.h" #define DHTPIN 4 #define DHTTYPE DHT22 #define MQ2_PIN 34 #define FLAME_PIN 27 #define BUZZER 26 #define LED 25 DHT dht(DHTPIN, DHTTYPE); const char* ssid = "YOUR_WIFI"; const char* password = "YOUR_PASSWORD"; String botToken = "YOUR_TELEGRAM_BOT_TOKEN"; String chatID = "YOUR_CHAT_ID"; String thingSpeakApi = "YOUR_THINGSPEAK_API_KEY"; void setup() { Serial.begin(115200); pinMode(FLAME_PIN, INPUT); pinMode(BUZZER, OUTPUT); pinMode(LED, OUTPUT); dht.begin(); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(1000); Serial.println("Connecting..."); } Serial.println("WiFi Connected"); } void sendTelegram(String message) { HTTPClient http; String url = "https://api.telegram.org/bot" + botToken + "/sendMessage?chat_id=" + chatID + "&text=" + message; http.begin(url); http.GET(); http.end(); } void sendThingSpeak(float temp, int smoke) { HTTPClient http; String url = "http://api.thingspeak.com/update?api_key=" + thingSpeakApi + "&field1=" + String(temp) + "&field2=" + String(smoke); http.begin(url); http.GET(); http.end(); } void loop() { float temperature = dht.readTemperature(); int smoke = analogRead(MQ2_PIN); int flame = digitalRead(FLAME_PIN); Serial.println(smoke); if (smoke > 2500 || flame == 0 || temperature > 50) { digitalWrite(BUZZER, HIGH); digitalWrite(LED, HIGH); sendTelegram("๐Ÿ”ฅ FIRE ALERT DETECTED!"); sendThingSpeak(temperature, smoke); delay(5000); } else { digitalWrite(BUZZER, LOW); digitalWrite(LED, LOW); } delay(2000); } 9. n8n Automation Workflow Workflow Features The n8n automation: Receives webhook data Checks fire thresholds Generates AI response Sends Telegram message Creates voice alert Logs to Google Sheets Updates dashboards n8n Workflow Steps Webhook Trigger Parse Sensor Data AI Decision Node Telegram Notification Text-to-Speech Node Google Sheets Append Emergency Alert Routing Sample 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" } ] } 10. Telegram Bot Setup Step 1: Create Bot Open Telegram and search: Telegram Search for: BotFather Commands: /newbot Copy: Bot Token Step 2: Get Chat ID Send message to your bot. Open: https://api.telegram.org/bot/getUpdates Copy: Chat ID 11. Google Sheets Integration Requirements Google Cloud Project Google Sheets API Service Account Steps Create Google Sheet Enable Sheets API Generate credentials JSON Connect Google Sheets node in n8n Map: Time Smoke Level Temperature Alert Status 12. ThingSpeak Cloud Dashboard Setup Using: ThingSpeak Official Platform Steps Create account Create channel Add fields: Temperature Smoke Fire Status Copy Write API Key Paste into ESP32 code 13. AI Power Consumption Prediction Logic The AI agent estimates power usage based on: Sensor sampling rate WiFi transmission frequency Alarm activation duration CPU active time Formula P=V×I Where: P = Power V = Voltage I = Current Prediction Model predicted_power = (sensor_reads * 0.02) + (wifi_transmissions * 0.15) + (alarm_usage * 0.4) AI can optimize: Sleep intervals Upload timing Sensor polling frequency 14. Voice Notification Automation Workflow Fire Detected ↓ n8n Receives Data ↓ AI Generates Alert Text ↓ Text-to-Speech Conversion ↓ Telegram Voice Message ↓ Emergency Notification Example Voice Alert “Warning! Fire and smoke detected in the monitored area. Please take immediate action.” 15. Cloud Dashboard Features Dashboard Displays Real-time temperature Smoke graph Alert history AI prediction status Device online/offline Notification logs 16. Future Enhancements AI Enhancements Machine learning fire prediction Computer vision smoke detection AI camera integration Edge AI analytics Hardware Enhancements GSM backup alerts Solar-powered ESP32 Battery backup Multi-room deployment Software Enhancements Mobile app MQTT architecture Firebase integration Voice assistant support 17. Deployment Guide Suitable Locations Smart homes Industries Warehouses Laboratories Server rooms Smart buildings 18. Advantages ✅ Low cost ✅ Real-time monitoring ✅ AI-enabled automation ✅ Cloud accessible ✅ Expandable architecture ✅ Remote alerts ✅ Energy efficient 19. Applications Smart Home Safety Industrial Fire Detection Warehouse Monitoring Forest Fire Early Warning Smart Cities Data Center Protection 20. Conclusion This project combines: IoT ESP32 AI automation Cloud monitoring Real-time emergency alerts to create an intelligent fire and smoke detection ecosystem capable of proactive safety monitoring and smart emergency response. The integration of: ESP32 n8n workflows Telegram voice alerts Google Sheets ThingSpeak AI-based automation

AI-Powered Home Automation Using Voice and Face Recognition

๐Ÿ  AI-Powered Home Automation Using Voice & Face Recognition (ESP32 + Agentic IoT + n8n + Telegram + Google Sheets + ThingSpeak) ๐Ÿ  AI-...