Saturday, 30 May 2026

AI Smart Baby Monitoring System with Cry and Motion Detection

AI Smart Baby Monitoring System with Cry and Motion Detection AI-Powered ESP32 + Agentic IoT + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard
AI Smart Baby Monitoring System with Cry and Motion Detection AI-Powered ESP32 + Agentic IoT + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard 1. Project Overview This project is an intelligent baby monitoring system that continuously monitors: Baby crying sounds Baby movement/motion Room temperature and humidity Activity patterns The system uses: ESP32 for edge sensing AI logic for event detection and prediction n8n for workflow automation Telegram Bot for instant voice alerts Google Sheets for data logging ThingSpeak for IoT dashboard visualization AI Agent for decision making and prediction 2. Objectives The system should: ✅ Detect baby crying ✅ Detect baby movement ✅ Send Telegram notifications ✅ Generate voice alerts ✅ Store historical data ✅ Visualize data on dashboard ✅ Predict high-activity periods ✅ Provide remote monitoring 3. System Architecture +------------------+ | Baby Room | +------------------+ | -------------------------------- | | Sound Sensor PIR Sensor (Cry Detection) (Motion Detection) | | ---------- ESP32 -------------- | | WiFi Internet | ----------------------------------- | | | | ThingSpeak n8n Server Google Sheet AI Agent | | | | ----------------------------------- | Telegram Bot | Voice Notification | Parent 4. Components List Main Controller Component Quantity ESP32 Dev Board 1 Sensors Component Quantity KY-038 Sound Sensor 1 PIR Motion Sensor HC-SR501 1 DHT22 Temperature Sensor 1 Output Devices Component Quantity LED Indicator 1 Buzzer 1 Communication Component Quantity WiFi Router 1 Software Arduino IDE n8n Telegram Bot Google Sheets ThingSpeak OpenAI API (optional AI agent) Google TTS API 5. Working Principle Cry Detection Sound sensor measures sound intensity. Sound > Threshold If: Sound Level > 2000 then: Baby Cry Event generated. Motion Detection PIR sensor detects movement. Motion = HIGH means baby movement detected. AI Decision Layer If: Cry + Motion occur together: Severity = HIGH If: Cry only Severity = MEDIUM If: Motion only Severity = LOW 6. Circuit Schematic Diagram ESP32 -------------------- GPIO34 <-- Sound Sensor AO GPIO27 <-- PIR OUT GPIO4 <-- DHT22 DATA GPIO2 --> LED GPIO15 --> Buzzer 3.3V --> DHT22 VCC 5V --> PIR VCC GND --> All GND 7. Pin Configuration ESP32 Pin Device GPIO34 Sound Sensor GPIO27 PIR Sensor GPIO4 DHT22 GPIO2 LED GPIO15 Buzzer 8. Flowchart START | Initialize ESP32 | Connect WiFi | Read Sensors | +----------------+ | Cry Detected ? | +----------------+ | YES | Send Alert | +------------------+ | Motion Detected? | +------------------+ | YES | High Priority Alert | Upload Data | Store in Sheet | Update Dashboard | AI Prediction | Repeat 9. ESP32 Source Code #include #include #include #define SOUND_PIN 34 #define PIR_PIN 27 #define DHTPIN 4 #define DHTTYPE DHT22 #define LED_PIN 2 #define BUZZER_PIN 15 const char* ssid = "YOUR_WIFI"; const char* password = "YOUR_PASSWORD"; String webhookURL = "https://your-n8n-server/webhook/baby-monitor"; DHT dht(DHTPIN, DHTTYPE); void setup() { Serial.begin(115200); pinMode(PIR_PIN, INPUT); pinMode(LED_PIN, OUTPUT); pinMode(BUZZER_PIN, OUTPUT); WiFi.begin(ssid,password); while(WiFi.status()!=WL_CONNECTED) { delay(500); } dht.begin(); } void loop() { int soundLevel = analogRead(SOUND_PIN); int motion = digitalRead(PIR_PIN); float temp = dht.readTemperature(); float hum = dht.readHumidity(); String eventType="NORMAL"; if(soundLevel > 2000) { eventType="CRY"; } if(motion==HIGH) { eventType="MOTION"; } if(soundLevel > 2000 && motion==HIGH) { eventType="CRY_MOTION"; } if(eventType!="NORMAL") { digitalWrite(LED_PIN,HIGH); tone(BUZZER_PIN,1000); sendData(eventType,soundLevel,motion,temp,hum); delay(5000); } digitalWrite(LED_PIN,LOW); delay(1000); } void sendData(String eventType, int sound, int motion, float temp, float hum) { if(WiFi.status()==WL_CONNECTED) { HTTPClient http; http.begin(webhookURL); http.addHeader( "Content-Type", "application/json"); String payload = "{"; payload += "\"event\":\""+eventType+"\","; payload += "\"sound\":"+String(sound)+","; payload += "\"motion\":"+String(motion)+","; payload += "\"temp\":"+String(temp)+","; payload += "\"humidity\":"+String(hum); payload += "}"; http.POST(payload); http.end(); } } 10. Telegram Bot Setup Step 1 Open Telegram Search: @BotFather Create Bot: /newbot Example: BabyMonitorBot Get: BOT TOKEN Save token. Step 2 Get Chat ID Send message to bot. Visit: https://api.telegram.org/botTOKEN/getUpdates Copy: chat_id 11. n8n Workflow Design Workflow: Webhook | Function | IF Node | Telegram | Google Sheets | ThingSpeak | AI Agent 12. n8n Step-by-Step Node 1: Webhook Method: POST Path: baby-monitor Receives ESP32 data. Node 2: Function Node return [{ json:{ event:$json.event, severity: $json.event=="CRY_MOTION"? "HIGH": "MEDIUM" } }] Node 3: IF Node Condition: severity = HIGH Node 4: Telegram Node Message: 🚨 Baby Crying and Moving! Immediate attention required. 13. Voice Notification Automation Method 1 Google Text-To-Speech API Generate: Attention. Baby is crying and moving. Please check immediately. MP3 generated. n8n Telegram Send Audio Node: Telegram → Send Audio Audio File: generated_voice.mp3 Parent receives voice alert. 14. Google Sheets Integration Create Sheet: Baby Monitoring Logs Columns: | Timestamp | | Event | | Sound | | Motion | | Temp | | Humidity | | Severity | Google Sheets Node Operation: Append Row Mapping: Date Event Sound Motion Temp Humidity Severity 15. ThingSpeak Setup Create account: ThingSpeak Official Website Create Channel Fields: Field1 = Sound Field2 = Motion Field3 = Temperature Field4 = Humidity Get: WRITE API KEY Upload Example https://api.thingspeak.com/update? api_key=XXXX &field1=1500 &field2=1 &field3=30 &field4=60 16. AI Power Consumption Prediction Logic Purpose: Estimate future power usage. Features: Sensor Activity Count WiFi Usage Alert Frequency Operating Hours Dataset Example Activity Alerts Power 10 2 0.5Wh 50 10 1.2Wh 100 20 2.5Wh AI Formula Linear Regression: y=a+bx a b Where: y = Predicted Power x = Activity Count Prediction Example: Current Activity = 80 Predicted: 2.0 Wh 17. AI Agentic Layer The AI agent receives: { "event":"CRY_MOTION", "sound":2450, "motion":1, "temp":31, "humidity":58 } AI analyzes: Severity Frequency Trend Repeated crying pattern Response: Baby has cried 5 times in the last hour. Activity level is increasing. Recommend immediate check. 18. Advanced AI Features Pattern Analysis Detect: Frequent Crying Night Disturbances Abnormal Activity Predictive Alerts Example: Baby usually cries around 2 AM. AI sends early warning. Anomaly Detection If: No motion for long time or Continuous crying Generate emergency notification. 19. Complete n8n Workflow JSON Structure { "nodes":[ { "name":"Webhook" }, { "name":"Function" }, { "name":"Telegram" }, { "name":"GoogleSheets" }, { "name":"ThingSpeak" } ] } In a real deployment, export the workflow from n8n after configuring credentials and node IDs. 20. Testing Procedure Test 1 Clap near microphone. Expected: Cry Alert Test 2 Move in front of PIR. Expected: Motion Alert Test 3 Cry + Motion Expected: High Priority Alert Voice Notification 21. Future Enhancements Computer Vision Add: ESP32-CAM Face Detection Sleep Monitoring Edge AI Use: TinyML TensorFlow Lite Micro For actual cry classification instead of simple sound threshold detection. Health Monitoring Add: Heart rate sensor Oxygen sensor Breathing sensor Mobile App Develop: Flutter App Android App iOS App 22. Deployment Guide Hardware Deployment Mount sensors near crib (not within baby's reach). Place microphone 1–2 meters away. Install PIR sensor with full crib coverage. Use a stable 5V/2A power supply. Connect ESP32 to a reliable Wi-Fi network. Software Deployment Upload ESP32 firmware. Configure Telegram Bot token. Configure n8n webhook URL. Connect Google Sheets credentials. Configure ThingSpeak API key. Test all alert paths. Enable automatic backups of logs. 23. Expected Outputs Telegram Alert 🚨 HIGH PRIORITY Baby Crying Detected Motion Detected Temperature: 30°C Humidity: 60% Please check immediately. Voice Alert Attention. Baby is crying and moving. Please check the baby immediately. Dashboard Live sound level graph Motion activity graph Temperature trend Humidity trend Alert history AI prediction chart 24. Project Outcomes This solution combines: ESP32 IoT Edge Computing Cry Detection Motion Detection Agentic AI Decision Making n8n Automation Telegram Voice Notifications Google Sheets Logging ThingSpeak Analytics Predictive AI Monitoring The result is a low-cost, scalable, cloud-connected smart baby monitoring platform suitable for homes, daycare centers, hospitals, and research environments.

Friday, 29 May 2026

AI Smart Autonomous Delivery Robot with Obstacle Avoidance

AI Smart Autonomous Delivery Robot with Obstacle Avoidance AI-Powered ESP32 + Agentic IoT + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard
AI Smart Autonomous Delivery Robot with Obstacle Avoidance AI-Powered ESP32 + Agentic IoT + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard 1. Project Overview This project combines: Autonomous delivery robot Obstacle avoidance navigation ESP32 Wi-Fi connectivity AI-powered decision making Agentic IoT architecture n8n workflow automation Telegram voice notification alerts Google Sheets data logging ThingSpeak cloud dashboard AI power consumption prediction Remote monitoring through web dashboard The robot can: ✅ Navigate autonomously ✅ Detect and avoid obstacles ✅ Monitor battery level ✅ Send live telemetry to cloud ✅ Log data into Google Sheets ✅ Generate AI-based battery usage predictions ✅ Send Telegram text and voice notifications ✅ Trigger automation workflows using n8n 2. System Architecture ┌─────────────────┐ │ Autonomous Robot │ │ ESP32 │ └────────┬────────┘ │ ┌────────────────┼─────────────────┐ │ │ │ ▼ ▼ ▼ HC-SR04 Battery Sensor Motor Driver Obstacle Monitoring L298N │ ▼ WiFi Connection │ ▼ n8n Automation │ ┌───────────┬───────┼──────────┐ ▼ ▼ ▼ ▼ Telegram AI Agent Google ThingSpeak Voice Alerts Sheets Dashboard 3. Components List Controller ESP32 DevKit V1 Navigation HC-SR04 Ultrasonic Sensor Servo Motor SG90 Motor Section L298N Motor Driver 2 DC Geared Motors Robot Chassis Wheels Power 18650 Battery Pack Battery Holder TP4056 Charging Module Sensors Voltage Divider Battery Sensor Optional: IR Sensors MPU6050 IMU Communication WiFi (ESP32 Built-in) Cloud Services Telegram Bot Google Sheets ThingSpeak n8n Server OpenAI API (optional) 4. Pin Connections HC-SR04 VCC → 5V GND → GND TRIG → GPIO5 ECHO → GPIO18 Servo Signal → GPIO19 VCC → 5V GND → GND L298N IN1 → GPIO26 IN2 → GPIO27 IN3 → GPIO14 IN4 → GPIO12 Battery Sensor Voltage Divider Output → GPIO34 5. Circuit Schematic Diagram HC-SR04 ┌─────────┐ Trig│ GPIO5 │ Echo│ GPIO18 │ └─────────┘ ESP32 ┌────────────────┐ │ │ │ GPIO26 ─ IN1 │ │ GPIO27 ─ IN2 │ │ GPIO14 ─ IN3 │ │ GPIO12 ─ IN4 │ │ GPIO19 ─ Servo │ │ GPIO34 ← Batt │ └────────────────┘ │ ▼ L298N ┌────────────┐ MotorA│ │MotorB └────────────┘ 6. Working Principle Step 1 Robot moves forward. Step 2 HC-SR04 continuously measures distance. Step 3 If obstacle detected: Distance < 20 cm Robot stops. Step 4 Servo rotates ultrasonic sensor. Left Scan Right Scan Step 5 Robot chooses best path. Step 6 Status uploaded to: ThingSpeak n8n webhook Step 7 n8n workflow: Stores data Runs AI analysis Sends Telegram alerts 7. Flowchart START │ ▼ Connect WiFi │ ▼ Read Sensors │ ▼ Obstacle? │ │ NO YES │ │ ▼ ▼ Move Stop Forward │ ▼ Scan Left │ ▼ Scan Right │ ▼ Best Direction │ ▼ Move │ ▼ Upload Data │ ▼ Repeat 8. ESP32 Source Code Required Libraries WiFi.h HTTPClient.h ESP32Servo.h WiFi Setup const char* ssid="YOUR_WIFI"; const char* password="YOUR_PASSWORD"; ThingSpeak String apiKey="THINGSPEAK_API_KEY"; n8n Webhook String webhook = "https://your-n8n-instance/webhook/robot"; Main Functions void moveForward() { digitalWrite(IN1,HIGH); digitalWrite(IN2,LOW); digitalWrite(IN3,HIGH); digitalWrite(IN4,LOW); } void stopRobot() { digitalWrite(IN1,LOW); digitalWrite(IN2,LOW); digitalWrite(IN3,LOW); digitalWrite(IN4,LOW); } Distance Measurement long readDistance() { digitalWrite(TRIG,LOW); delayMicroseconds(2); digitalWrite(TRIG,HIGH); delayMicroseconds(10); digitalWrite(TRIG,LOW); long duration=pulseIn(ECHO,HIGH); return duration*0.034/2; } Upload Data void sendData() { HTTPClient http; String url= webhook+ "?distance="+String(distance)+ "&battery="+String(battery); http.begin(url); http.GET(); http.end(); } 9. n8n Workflow Design Workflow Nodes Webhook │ ▼ Function │ ▼ OpenAI │ ▼ Google Sheets │ ▼ Telegram Workflow Logic Webhook receives: { "distance": 35, "battery": 72, "status": "MOVING" } Function Node: return [{ battery:$json.battery, distance:$json.distance, status:$json.status }] 10. AI Agent Logic AI Agent receives: Battery = 72% Distance = 35cm Current State = Moving Prompt: Analyze robot health. Predict battery life. Suggest maintenance action. Output: Battery healthy. Estimated operation: 2.8 Hours Remaining. No maintenance required. 11. n8n Workflow JSON Template { "nodes":[ { "name":"Webhook" }, { "name":"OpenAI" }, { "name":"Google Sheets" }, { "name":"Telegram" } ] } Import this JSON into n8n and configure credentials. 12. Telegram Bot Setup Create Bot Open Telegram. Search: @BotFather Commands: /newbot Provide: Robot Delivery Bot Receive: BOT TOKEN Get Chat ID Send message to bot. Open: Telegram Bot API Documentation Retrieve: chat_id 13. Telegram Voice Alert Automation n8n Telegram Node Message: Warning! Obstacle detected. Battery below 20%. Voice Conversion Use: Google Cloud Text-to-Speech or ElevenLabs Workflow: Webhook │ ▼ AI Analysis │ ▼ Text-to-Speech │ ▼ Telegram Send Audio Voice Alert Example: Attention. Delivery robot battery is low. Please recharge soon. 14. Google Sheets Integration Create Sheet: RobotData Columns: Timestamp Distance Battery Status Prediction Example: Time Distance Battery Status Prediction 10:00 45 75 Moving 3 hrs n8n Configuration Add: Google Sheets Node Authentication: OAuth2 Operations: Append Row 15. ThingSpeak Cloud Dashboard Setup Create account: ThingSpeak Official Website Create Channel: Fields: Field1 Distance Field2 Battery Field3 Status Field4 AI Prediction Upload API https://api.thingspeak.com/update Example: field1=35 field2=78 field3=1 16. AI Power Consumption Prediction Inputs Battery Voltage Motor Speed Distance Travelled Obstacle Count Operating Time Formula Basic estimation: Remaining Time = Battery Capacity / Current Consumption Example: 2200mAh / 750mA = 2.93 Hours For visualization: t= I C ​ Where: t = operating time C = battery capacity I = current consumption Advanced AI Model Features: Battery Voltage Motor PWM Obstacle Frequency Average Speed Temperature Model: Linear Regression or Random Forest Prediction: Remaining Battery % Expected Runtime Maintenance Alert 17. Web Dashboard Recommended stack: ESP32 ThingSpeak n8n Telegram Google Sheets Advanced dashboard: React Node.js MQTT Broker AI Analytics Useful platforms: Node-RED Grafana MQTT HiveMQ Cloud 18. Future Enhancements AI Navigation Computer Vision Object Classification Dynamic Route Planning Use: OpenCV YOLO Object Detection Mapping SLAM Indoor Navigation GPS Delivery Modules: NEO-6M GPS Voice Assistant Commands: Start Delivery Return Home Battery Status Emergency Stop Edge AI Models: TinyML TensorFlow Lite Micro Use: TensorFlow Lite for Microcontrollers 19. Deployment Guide Phase 1 Hardware Assembly Assemble chassis Install motors Connect ESP32 Connect sensors Phase 2 Firmware Upload ESP32 code Verify sensor readings Phase 3 Cloud Setup Configure ThingSpeak Configure Telegram Configure Google Sheets Phase 4 Automation Deploy n8n workflow Connect OpenAI API Test alerts Phase 5 Field Testing Obstacle avoidance test Battery monitoring test Cloud connectivity test Telegram voice alert test Phase 6 Production Deployment Waterproof enclosure High-capacity battery OTA firmware updates Secure API keys Fleet monitoring dashboard Final Deliverable Features ✅ Autonomous obstacle avoidance robot ✅ ESP32 Wi-Fi enabled ✅ Agentic AI decision layer ✅ n8n automation workflows ✅ Telegram text and voice alerts ✅ Google Sheets logging ✅ ThingSpeak real-time dashboard ✅ AI battery prediction ✅ Cloud monitoring ✅ Future-ready for computer vision, SLAM, GPS, and multi-robot fleet management This architecture is suitable as a complete final-year engineering project, IoT research prototype, smart campus delivery robot, hospital medicine delivery robot, or warehouse autonomous delivery system.

AI Smart Anti-Sleep Alarm System for Drivers Using CNN

AI Smart Anti-Sleep Alarm System for Drivers Using CNN + ESP32 + Agentic IoT + n8n + Telegram Voice Alerts + Google Sheets + ThingSpeak
AI Smart Anti-Sleep Alarm System for Drivers Using CNN + ESP32 + Agentic IoT + n8n + Telegram Voice Alerts + Google Sheets + ThingSpeak 1. Project Overview Project Title AI Smart Anti-Sleep Alarm System for Drivers Using CNN, ESP32, Agentic IoT, n8n Automation, Telegram Voice Alerts, Google Sheets Logging, and ThingSpeak Dashboard Objective The system continuously monitors a driver's face using a camera and uses a Convolutional Neural Network (CNN) model to detect: Eye closure Yawning Head nodding Drowsiness level When drowsiness is detected: Local alarm activates. ESP32 receives alert. Data is uploaded to ThingSpeak. Google Sheets logs event. n8n workflow processes event. AI Agent analyzes driver condition. Telegram voice notification is sent. Emergency contact can be alerted. 2. System Architecture Camera │ ▼ CNN Drowsiness Detection │ ▼ Python Detection Program │ ▼ ESP32 WiFi Module │ ├── ThingSpeak Cloud │ ├── Google Sheets │ └── n8n Webhook │ ▼ AI Agent Analysis │ ▼ Telegram Voice Alert 3. Features AI Features ✔ CNN Driver Drowsiness Detection ✔ Real-Time Eye Monitoring ✔ Yawning Detection ✔ Driver Fatigue Scoring ✔ AI Power Consumption Prediction ✔ Event Classification IoT Features ✔ ESP32 WiFi Connectivity ✔ ThingSpeak Dashboard ✔ Cloud Data Logging ✔ Google Sheets Storage ✔ Remote Monitoring Automation Features ✔ n8n Workflow ✔ Telegram Voice Notification ✔ AI Agent Decision Making ✔ Alert Escalation 4. Hardware Components Component Quantity ESP32 Dev Board 1 ESP32-CAM or USB Webcam 1 Buzzer 1 LED 2 220Ω Resistor 2 OLED Display (Optional) 1 Breadboard 1 Jumper Wires Several Power Bank 1 Vehicle Adapter 5V 1 5. Software Requirements Programming Arduino IDE Python 3.11 Libraries Python: pip install opencv-python pip install tensorflow pip install keras pip install numpy pip install requests pip install mediapipe Arduino: WiFi.h HTTPClient.h ArduinoJson.h ThingSpeak.h 6. CNN Model Design Dataset Use: Driver Drowsiness Dataset Yawn Dataset Eye Blink Dataset Sources: Kaggle MRL Eye Dataset YawDD Dataset CNN Architecture Input Image │ ▼ Conv2D (32) │ ReLU │ Max Pooling │ Conv2D (64) │ ReLU │ Max Pooling │ Flatten │ Dense (128) │ Dropout │ Dense (2) │ Softmax Classes: 0 = Alert 1 = Drowsy CNN Training model.compile( optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'] ) model.fit( train_data, epochs=20, validation_data=val_data ) model.save("driver_drowsiness.h5") 7. Circuit Schematic ESP32 Connections Buzzer + -------- GPIO18 LED RED + -------- GPIO19 LED GREEN + -------- GPIO21 OLED SDA ---- GPIO22 OLED SCL ---- GPIO23 GND -------- Common Ground Wiring Diagram ESP32 +-----------+ | | 18 ---| Buzzer | 19 ---| Red LED | 21 ---| Green LED | 22 ---| SDA OLED | 23 ---| SCL OLED | +-----------+ 8. Flowchart Start │ Initialize Camera │ Capture Frame │ CNN Prediction │ Drowsy? ┌──No───────────┐ │ │ ▼ │ Normal │ │ │ Upload Data │ │ │ Loop │ │ Yes │ Activate Buzzer │ Send to ESP32 │ ThingSpeak Upload │ Google Sheets Log │ Trigger n8n │ AI Agent Analysis │ Telegram Voice Alert │ Repeat 9. ESP32 Source Code #include #include const char* ssid="YOUR_WIFI"; const char* password="PASSWORD"; String webhookURL = "https://your-n8n-server/webhook/drowsy"; #define BUZZER 18 void setup() { Serial.begin(115200); pinMode(BUZZER,OUTPUT); WiFi.begin(ssid,password); while(WiFi.status()!=WL_CONNECTED) { delay(500); } } void loop() { if(Serial.available()) { String status = Serial.readString(); if(status=="DROWSY") { digitalWrite(BUZZER,HIGH); HTTPClient http; http.begin(webhookURL); http.addHeader( "Content-Type", "application/json" ); String payload= "{\"status\":\"drowsy\"}"; http.POST(payload); http.end(); } } } 10. Python Detection Program import cv2 import tensorflow as tf import serial model = tf.keras.models.load_model( "driver_drowsiness.h5" ) esp = serial.Serial( 'COM5', 115200 ) cam = cv2.VideoCapture(0) while True: ret, frame = cam.read() img = cv2.resize( frame, (64,64) ) pred = model.predict( img.reshape(1,64,64,3) ) if pred.argmax()==1: esp.write( b'DROWSY' ) 11. ThingSpeak Setup Step 1 Create account: ThingSpeak Step 2 Create Channel Fields: Field1 = Drowsiness Score Field2 = Blink Count Field3 = Yawn Count Field4 = Battery Voltage Field5 = AI Risk Level Step 3 Get: Channel ID Write API Key ESP32 Upload Example ThingSpeak.writeField( channelID, 1, drowsyScore, apiKey ); 12. Google Sheets Integration Method ESP32 → n8n → Google Sheets Sheet Columns Timestamp Driver ID Drowsy Score Yawn Count Blink Count Alert Level Location Setup Create Google Sheet. Open n8n. Add Google Sheets Node. Connect Google Account. Select Sheet. Map fields. 13. n8n Workflow Design Workflow Webhook │ ▼ AI Agent │ ▼ IF Node │ ┌─┴─────┐ │ │ Low High │ │ ▼ ▼ Sheet Telegram Update Voice Alert Workflow Nodes Node 1 Webhook Receives: { "status":"drowsy", "score":85 } Node 2 OpenAI Agent Prompt: Analyze driver condition. Score = {{$json.score}} Generate alert level. Node 3 Google Sheets Append Row Node 4 Telegram Send Alert 14. Example n8n Workflow JSON { "nodes":[ { "name":"Webhook" }, { "name":"AI Agent" }, { "name":"Google Sheets" }, { "name":"Telegram" } ] } In a real deployment, export the completed workflow from n8n and replace the placeholder structure above with the generated JSON. 15. Telegram Bot Setup Create Bot Open: Telegram BotFather Commands: /start /newbot Get: BOT TOKEN Get Chat ID https://api.telegram.org/botTOKEN/getUpdates Send Message POST https://api.telegram.org/botTOKEN/sendMessage 16. Voice Notification Automation Method Text → Speech → Telegram Voice n8n Process Alert Generated │ ▼ OpenAI Agent │ Generate Message │ Google TTS │ MP3 File │ Telegram Send Voice Example Voice Message Warning. Driver fatigue detected. Drowsiness score is 88 percent. Please stop and rest immediately. 17. AI Agent Logic Prompt You are an AI safety officer. Input: Drowsiness Score Blink Rate Yawn Count Output: Risk Level Recommendation Example Output { "risk":"HIGH", "recommendation": "Stop vehicle immediately" } 18. AI Power Consumption Prediction The AI agent estimates battery and power usage. Inputs WiFi Signal CPU Usage Upload Frequency Battery Voltage Formula Use linear regression: P=V×I Where: P = Power V = Voltage I = Current Example Voltage = 5V Current = 0.24A Power = 1.2W The AI agent can predict remaining runtime and recommend reducing upload frequency if battery drops below a threshold. 19. Database Structure driver_events id timestamp driver_id score blink_count yawn_count risk_level gps_lat gps_long battery_voltage 20. Future Enhancements Phase 2 GPS Tracking GSM Emergency SMS Accident Detection Seatbelt Monitoring Phase 3 Edge AI on ESP32-S3 TinyML Deployment Offline AI Inference Face Recognition Phase 4 Fleet Management Dashboard Multi-Vehicle Monitoring Predictive Driver Fatigue Analytics AI Copilot Assistant 21. Deployment Guide Vehicle Installation Mount Camera Position camera toward driver's face. Ensure clear visibility in day and night conditions. Install ESP32 Place in dashboard enclosure. Connect to 5V vehicle adapter. Connect Cloud Configure Wi-Fi or hotspot. Verify ThingSpeak updates. Test Simulate eye closure. Confirm buzzer activates. Verify ThingSpeak receives data. Check Google Sheets log. Confirm Telegram voice alert delivery. Validate AI risk classification. Expected Outputs Local Buzzer alarm LED warning OLED status display Cloud ThingSpeak live dashboard Google Sheets logs AI Agent Risk assessment Safety recommendations Mobile Telegram notification Telegram voice alert Historical event tracking This architecture is suitable for a final-year B.Tech/M.Tech engineering project, research prototype, startup MVP, or commercial fleet-monitoring system, and can be extended with GPS, GSM, TinyML, and advanced Agentic AI workflows.

Thursday, 28 May 2026

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-Powered Home Automation Using Voice & Face Recognition (ESP32 + Agentic IoT + n8n + Telegram + Google Sheets + ThingSpeak) 1. 📌 Project Overview This project builds a smart home automation system using: ESP32 AI-based decision layer (agentic IoT logic) Workflow automation using n8n Real-time alerts via Telegram Cloud logging in Google Sheets IoT visualization in ThingSpeak Voice + Face recognition (AI layer on mobile/cloud/edge) 🎯 Core Idea: Your home devices (lights, fans, door lock, sensors) are controlled by ESP32, while AI + n8n + Telegram act as the brain for automation, alerts, and analytics. 2. 🧩 System Architecture 🔄 Flow: Sensors → ESP32 collects data ESP32 → sends data to ThingSpeak / Webhook n8n workflow → processes data AI Agent → makes decisions Telegram → sends voice/text alerts Google Sheets → logs all activity User → controls system via voice/face commands 3. 🧰 Components List Hardware: ESP32 Dev Board Relay Module (2/4 channel) PIR Motion Sensor DHT11/DHT22 (Temperature & Humidity) LDR (Light Sensor) Camera module (for face recognition) Buzzer / LED indicators Power supply (5V) Software: ESP32 firmware (Arduino IDE / PlatformIO) n8n ThingSpeak Google Sheets Telegram bot Python (AI voice + face recognition) OpenCV / Face Recognition library Google Text-to-Speech (for voice alerts) 4. ⚡ Circuit Schematic (Explanation) ESP32 connections: Component ESP32 Pin Relay IN1 GPIO 26 Relay IN2 GPIO 27 PIR Sensor GPIO 14 DHT11 GPIO 4 LDR (Analog) GPIO 34 Buzzer GPIO 25 Camera Module: Connected via ESP32-CAM or external AI module 5. 🔁 System Flowchart Start ↓ ESP32 reads sensors ↓ Send data to ThingSpeak / Webhook ↓ n8n workflow triggered ↓ AI Agent processes data ↓ Decision: ├── Normal → Log to Google Sheets ├── Alert → Send Telegram message ├── Critical → Voice alert + automation ON/OFF ↓ User feedback received ↓ Action executed on ESP32 6. 💻 ESP32 Source Code (Basic Example) #include #include #include "DHT.h" #define DHTPIN 4 #define DHTTYPE DHT11 DHT dht(DHTPIN, DHTTYPE); const char* ssid = "YOUR_WIFI"; const char* password = "YOUR_PASS"; void setup() { Serial.begin(115200); WiFi.begin(ssid, password); dht.begin(); pinMode(26, OUTPUT); // Relay } void loop() { float temp = dht.readTemperature(); float hum = dht.readHumidity(); Serial.println(temp); if (WiFi.status() == WL_CONNECTED) { HTTPClient http; String url = "https://api.thingspeak.com/update?api_key=YOUR_KEY&field1=" + String(temp); http.begin(url); http.GET(); http.end(); } delay(5000); } 7. ⚙️ n8n Workflow Setup Steps: Open n8n Create new workflow Nodes: 1. Webhook Node Receives ESP32 / ThingSpeak data 2. Function Node (AI Logic) if (items[0].json.temp > 35) { return [{ alert: "HIGH TEMP" }]; } return [{ alert: "NORMAL" }]; 3. Telegram Node Send alert message 4. Google Sheets Node Append row (logs data) 5. HTTP Request Node Send command back to ESP32 8. 🤖 Telegram Bot Setup Steps: Open Telegram Search BotFather Create bot Get API token Use in n8n: Connect bot token Configure chat ID Enable: Text alerts Voice messages (TTS) 9. 📊 Google Sheets Integration Structure: Time Temperature Humidity Status Action n8n does: Append row every event Maintain historical analytics 10. ☁️ ThingSpeak Setup Steps: Create channel Add fields: Temperature Humidity Motion Copy API key ESP32 sends data every 10 sec 11. 🧠 AI Power Consumption Prediction Logic Logic idea: if temp > 30 and motion == 1: power_usage = "HIGH" elif temp < 25: power_usage = "LOW" else: power_usage = "MEDIUM" Advanced AI upgrade: Use regression model: Input: temperature, motion, time Output: predicted energy usage 12. 🔊 Voice Notification System Workflow: Event triggers in n8n Text converted to speech Sent via Telegram voice message Example: “Warning! High temperature detected in living room.” 13. 📷 Face Recognition System Process: ESP32-CAM captures image Python/OpenCV processes face Compare with stored dataset Decision: Known user → Unlock door Unknown → Alert sent 14. 🚨 Automation Logic Examples Condition Action Motion detected Turn ON light Temp > 35°C Fan ON Unknown face Send Telegram alert No motion Turn OFF devices 15. 🔌 ESP32 ↔ n8n Communication Two methods: Method 1: Webhook (Recommended) ESP32 sends HTTP POST to n8n Method 2: ThingSpeak polling n8n fetches data periodically 16. 📈 Dashboard Setup In ThingSpeak: Live graphs: Temperature Humidity Motion Historical trends Export CSV 17. 🚀 Future Enhancements AI upgrades: Full edge AI on ESP32-S3 Voice assistant integration Emotion detection via camera Predictive maintenance AI IoT upgrades: Smart energy billing Solar energy integration MQTT-based scalable architecture Automation upgrades: Multi-room smart control Mobile app dashboard AI chatbot control system 18. 📦 Final Deployment Guide Flash ESP32 code Setup WiFi connection Deploy n8n workflow Connect Telegram bot Configure ThingSpeak API Link Google Sheets Test sensor triggers Enable AI logic Deploy face recognition system 🎯 Final Output You will get: Real-time smart home control AI-based decision automation Telegram alerts (text + voice) Cloud logging dashboard Face + voice recognition security Predictive energy monitoring

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 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...