SVSEmbedded will do new innovative thoughts. Any latest idea will comes we will take that idea & implement that idea in a few days. We always encourage the students to take good ideas/projects. SVSEmbedded providing latest innovative electronics projects to B.E/B.Tech/M.E/M.Tech students. We developed thousands of projects for engineering student to develop their skills in electrical and electronics
Saturday, 30 May 2026
AI Smart Power Factor Correction with Load Prediction
AI Smart Power Factor Correction with Load Prediction
ESP32 + Agentic AI + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard
AI Smart Power Factor Correction with Load Prediction
ESP32 + Agentic AI + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard
1. Project Overview
Project Title
AI-Powered Smart Power Factor Correction System with Load Prediction using ESP32, n8n Automation, Telegram Voice Alerts, Google Sheets Logging, and ThingSpeak Cloud Dashboard
Project Objective
Develop an intelligent energy monitoring and power factor correction system that:
Measures Voltage, Current, Power, Energy, and Power Factor.
Automatically switches capacitor banks for power factor correction.
Uses AI-based prediction to forecast future power consumption.
Sends voice alerts through Telegram.
Stores historical data in Google Sheets.
Visualizes real-time data on ThingSpeak.
Uses n8n as the automation and AI orchestration platform.
Supports future Agentic AI decision-making.
2. System Architecture
┌────────────────────┐
│ Electrical Load │
└──────────┬─────────┘
│
Voltage & Current
│
┌─────────▼────────┐
│ PZEM004T │
│ Energy Meter │
└─────────┬────────┘
│ UART
┌─────────▼────────┐
│ ESP32 │
│ Data Collection │
└─────────┬────────┘
│ WiFi
┌──────────────────┼─────────────────┐
│ │ │
▼ ▼ ▼
ThingSpeak n8n Workflow Google Sheets
│
▼
AI Prediction Engine
│
▼
Telegram Bot
│
Voice Alerts
▼
Power Factor Control
Relay Bank
3. Features
Monitoring
Voltage
Current
Active Power
Apparent Power
Reactive Power
Power Factor
Energy Consumption
Automation
Automatic capacitor switching
AI load forecasting
Telegram alerts
Voice notifications
Cloud
ThingSpeak Dashboard
Google Sheets Storage
Historical Analytics
AI Features
Consumption Prediction
Anomaly Detection
Peak Demand Forecasting
Future Agentic Actions
4. Components Required
Component Quantity
ESP32 Dev Board 1
PZEM-004T v3 Energy Meter 1
ZMPT101B Voltage Sensor (optional) 1
SCT013 Current Sensor (optional) 1
5V Relay Module 4
Capacitor Banks 4
Capacitors (2µF,4µF,8µF,16µF) As required
Power Supply 5V 1
WiFi Router 1
Breadboard/PCB 1
Jumper Wires Multiple
Telegram Bot 1
ThingSpeak Account 1
Google Account 1
n8n Server 1
5. Power Factor Correction Theory
Power Factor:
PF=
Apparent Power
Real Power
Ideal PF:
0.95 to 1.00
If PF drops:
PF < 0.90
Capacitor bank is switched ON.
Example:
PF = 0.72
Relay 1 ON
PF = 0.65
Relay 1 + Relay 2 ON
PF = 0.55
Relay 1 + Relay 2 + Relay 3 ON
6. Circuit Connections
ESP32 ↔ PZEM004T
PZEM ESP32
TX GPIO16
RX GPIO17
VCC 5V
GND GND
Relay Module
Relay ESP32
Relay1 GPIO25
Relay2 GPIO26
Relay3 GPIO27
Relay4 GPIO14
Capacitor Banks
Relay1 → 2uF
Relay2 → 4uF
Relay3 → 8uF
Relay4 →16uF
Connected parallel to load.
7. Circuit Schematic
AC LOAD
│
┌──▼──┐
│PZEM │
└──┬──┘
│
▼
ESP32
│
┌──┼───────────────┐
│ │ │ │ │
▼ ▼ ▼ ▼ ▼
R1 R2 R3 R4 WiFi
│ │ │ │
▼ ▼ ▼ ▼
Capacitor Bank
8. Flowchart
START
│
▼
Connect WiFi
│
▼
Read PZEM Data
│
▼
Calculate PF
│
▼
PF < 0.90 ?
┌──Yes──┐
▼ ▼
Enable No Action
Capacitor
│
▼
Send Data
│
▼
ThingSpeak
│
▼
n8n Webhook
│
▼
AI Prediction
│
▼
Store in Sheets
│
▼
Send Telegram Alert
│
▼
Repeat
9. ESP32 Source Code
Libraries
Install:
PZEM004Tv30
WiFi
HTTPClient
ArduinoJson
Main Code
#include
#include
#include
PZEM004Tv30 pzem(Serial2,16,17);
const char* ssid="YOUR_WIFI";
const char* pass="PASSWORD";
String webhookURL =
"https://n8n-server/webhook/power";
#define RELAY1 25
#define RELAY2 26
#define RELAY3 27
#define RELAY4 14
void setup()
{
Serial.begin(115200);
pinMode(RELAY1,OUTPUT);
pinMode(RELAY2,OUTPUT);
pinMode(RELAY3,OUTPUT);
pinMode(RELAY4,OUTPUT);
WiFi.begin(ssid,pass);
while(WiFi.status()!=WL_CONNECTED)
{
delay(500);
}
}
void loop()
{
float voltage=pzem.voltage();
float current=pzem.current();
float power=pzem.power();
float pf=pzem.pf();
if(pf<0.90)
{
digitalWrite(RELAY1,HIGH);
}
if(pf<0.80)
{
digitalWrite(RELAY2,HIGH);
}
if(pf<0.70)
{
digitalWrite(RELAY3,HIGH);
}
if(pf<0.60)
{
digitalWrite(RELAY4,HIGH);
}
HTTPClient http;
http.begin(webhookURL);
http.addHeader("Content-Type",
"application/json");
String payload="{\"voltage\":"
+String(voltage)+
",\"current\":"
+String(current)+
",\"power\":"
+String(power)+
",\"pf\":"
+String(pf)+"}";
http.POST(payload);
http.end();
delay(30000);
}
10. ThingSpeak Setup
Create channel.
Fields:
Field1 Voltage
Field2 Current
Field3 Power
Field4 PF
Field5 Energy
Field6 Predicted Load
Get:
Write API Key
Channel ID
ESP32 sends data every 30 seconds.
Example URL:
https://api.thingspeak.com/update
Parameters:
api_key=XXXX
field1=230
field2=5
field3=1100
field4=0.92
11. Google Sheets Integration
Create Sheet:
Timestamp
Voltage
Current
Power
PF
Energy
Prediction
Status
n8n Google Sheet Node
Action:
Append Row
Every incoming ESP32 record gets stored.
12. Telegram Bot Setup
Open Telegram.
Search:
BotFather
Create bot:
/ newbot
Receive:
BOT TOKEN
Get Chat ID.
Save both.
13. Voice Alert System
Telegram supports voice files.
n8n workflow:
Incoming Data
│
▼
Function Node
│
▼
Text-to-Speech
│
▼
Telegram Send Audio
Example message:
Warning.
Power factor has dropped to
0.68
Capacitor bank activated.
Predicted load increase
within 30 minutes.
14. AI Load Prediction Logic
Dataset
Historical records:
Time
Voltage
Current
Power
Energy
PF
Prediction Inputs
Last 24 Hours
Features:
Hour
Day
Power
Current
Energy
Prediction Output
Next 30 min load
Next 1 hour load
Next 24 hour load
Simple AI Model
Linear Regression
Predicted_Load =
a+b(power)+c(current)+d(hour)
Advanced AI
Use:
XGBoost
Random Forest
LSTM
Prophet
15. n8n Workflow Design
Webhook Trigger
│
▼
Data Processing
│
▼
AI Agent Node
│
├─────────► ThingSpeak
│
├─────────► Google Sheets
│
├─────────► Telegram Text
│
└─────────► Telegram Voice
16. Example n8n Workflow JSON Structure
{
"nodes":[
{
"name":"Webhook"
},
{
"name":"Function"
},
{
"name":"Google Sheets"
},
{
"name":"Telegram"
}
]
}
In actual deployment export the workflow from n8n after configuration.
17. Agentic AI Extension
AI Agent receives:
PF
Voltage
Current
Historical Trends
Weather
Time
Agent decides:
Increase Capacitor
Decrease Capacitor
Peak Warning
Maintenance Alert
Example:
Predicted PF drop in 20 min
Activate 8uF capacitor now.
18. Telegram Alert Examples
Normal
System Healthy
PF = 0.97
Load = 1.1 kW
Warning
PF Low
PF = 0.75
Capacitor Activated
Critical
PF = 0.52
Maximum Capacitor Bank Active
Immediate inspection required
19. Future Enhancements
AI
LSTM Forecasting
Reinforcement Learning
Predictive Maintenance
Load Classification
Cloud
MQTT Broker
AWS IoT
Azure IoT Hub
Google Cloud IoT
Hardware
3-Phase Monitoring
Automatic Capacitor Bank Panel
Industrial PLC Integration
Mobile App
Flutter Dashboard
React Native Dashboard
AI Chat Assistant
20. Deployment Guide
Phase 1
Build hardware.
Verify:
Voltage readings
Current readings
PF readings
Phase 2
Configure:
WiFi
ThingSpeak
Telegram
Phase 3
Deploy n8n.
Recommended options:
Docker
VPS
Raspberry Pi
Phase 4
Connect:
ESP32 → n8n
n8n → Sheets
n8n → Telegram
n8n → ThingSpeak
Phase 5
Train AI Model
Collect:
1–4 weeks data
Train prediction model and integrate it into n8n or a Python microservice.
Final Outcome
This project becomes a complete Industry 4.0 Smart Energy Management System capable of:
Real-time electrical monitoring
Automatic power factor correction
AI-based load forecasting
Agentic decision-making
Cloud analytics
Google Sheets logging
ThingSpeak visualization
Telegram text and voice alerts
Scalable industrial deployment using ESP32 and n8n automation.
AI Smart Electric Vehicle Charging Station Management System
AI Smart Electric Vehicle Charging Station Management System
AI-Powered ESP32 + Agentic IoT + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard
AI Smart Electric Vehicle Charging Station Management System
AI-Powered ESP32 + Agentic IoT + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard
1. Project Overview
Project Title
AI Smart Electric Vehicle Charging Station Management System using ESP32, Agentic IoT, n8n Automation, Telegram Voice Alerts, Google Sheets, and ThingSpeak
Objective
Develop an intelligent EV charging station monitoring and management system that:
Monitors charging voltage, current, power, and energy consumption.
Predicts future power demand using AI.
Sends real-time alerts through Telegram.
Generates voice notifications automatically.
Stores charging logs in Google Sheets.
Visualizes data on ThingSpeak cloud dashboards.
Uses n8n as an automation and AI orchestration platform.
Supports future expansion into multiple charging stations.
2. System Architecture
EV Charger
│
▼
Current & Voltage Sensors
│
▼
ESP32 Controller
│
├────────► ThingSpeak Dashboard
│
├────────► n8n Webhook
│ │
│ ▼
│ AI Agent Logic
│ │
│ ┌─────────┴─────────┐
│ ▼ ▼
│ Google Sheets Telegram Bot
│ │
│ ▼
│ Voice Notification
│
▼
Cloud Monitoring
3. Features
Real-Time Monitoring
Voltage Monitoring
Current Monitoring
Power Calculation
Energy Consumption Tracking
AI Agent Features
Charging load prediction
Peak demand forecasting
Anomaly detection
Usage pattern analysis
Automation
Data logging
Alert generation
Voice message generation
Cloud dashboard updates
4. Components List
Component Quantity
ESP32 Dev Board 1
ACS712 Current Sensor 1
ZMPT101B Voltage Sensor 1
Relay Module 1
OLED Display 0.96" 1
EV Charging Socket 1
5V Power Supply 1
Jumper Wires Several
Breadboard/PCB 1
WiFi Router 1
5. Circuit Connections
ACS712 Current Sensor
ACS712 ESP32
VCC 5V
GND GND
OUT GPIO34
ZMPT101B Voltage Sensor
ZMPT101B ESP32
VCC 5V
GND GND
OUT GPIO35
Relay Module
Relay ESP32
IN GPIO26
VCC 5V
GND GND
OLED Display (I2C)
OLED ESP32
SDA GPIO21
SCL GPIO22
VCC 3.3V
GND GND
6. Circuit Schematic Diagram
+----------------+
| ESP32 |
| |
Voltage Sensor--| GPIO35 |
Current Sensor--| GPIO34 |
Relay ----------| GPIO26 |
OLED SDA -------| GPIO21 |
OLED SCL -------| GPIO22 |
+----------------+
|
WiFi
|
+-------------+-------------+
| |
ThingSpeak n8n Server
|
+----------------+----------------+
| | |
Telegram Bot Google Sheets AI Agent
7. Flowchart
Start
│
▼
Initialize ESP32
│
Connect WiFi
│
Read Sensors
│
Calculate Power
│
Upload ThingSpeak
│
Send Data to n8n
│
AI Analysis
│
Store in Sheets
│
Alert Required?
│
┌──Yes───┐
▼ ▼
Telegram Continue
Voice
Alert
│
▼
Loop
8. Working Principle
Step 1
ESP32 reads:
Voltage from ZMPT101B
Current from ACS712
Step 2
Calculate power:
P=V×I
Example:
Voltage = 230V
Current = 10A
Power = 230 × 10
= 2300 W
Step 3
Calculate Energy
E=P×t
Example:
2300W × 2h
= 4.6 kWh
Step 4
ESP32 sends data to:
ThingSpeak
n8n Webhook
Step 5
n8n processes data
Save logs
Trigger AI analysis
Send notifications
9. ESP32 Source Code
#include
#include
const char* ssid = "YOUR_WIFI";
const char* password = "YOUR_PASSWORD";
String webhookURL =
"https://your-n8n-server/webhook/evstation";
int voltagePin = 35;
int currentPin = 34;
void setup()
{
Serial.begin(115200);
WiFi.begin(ssid,password);
while(WiFi.status()!=WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
}
void loop()
{
float voltage =
analogRead(voltagePin)*(3.3/4095.0)*100;
float current =
analogRead(currentPin)*(3.3/4095.0)*30;
float power = voltage*current;
if(WiFi.status()==WL_CONNECTED)
{
HTTPClient http;
http.begin(webhookURL);
http.addHeader("Content-Type",
"application/json");
String payload="{";
payload+="\"voltage\":"+String(voltage)+",";
payload+="\"current\":"+String(current)+",";
payload+="\"power\":"+String(power);
payload+="}";
http.POST(payload);
http.end();
}
delay(15000);
}
10. ThingSpeak Setup
Create Channel
Sign up at ThingSpeak.
Create New Channel.
Add Fields:
Field1 = Voltage
Field2 = Current
Field3 = Power
Field4 = Energy
Save Channel.
Copy Write API Key.
ESP32 Upload URL
https://api.thingspeak.com/update
Example:
field1=230
field2=10
field3=2300
field4=4.5
11. Google Sheets Integration
Create columns:
Timestamp Voltage Current Power Energy Prediction
Example:
2026-05-30 10:15
230
10
2300
4.6
2500
12. Telegram Bot Setup
Create Bot
Open Telegram.
Search for:
Telegram
Open:
BotFather
Send:
/newbot
Enter Bot Name.
Copy Token.
Example:
123456:ABCDEFxxxx
Get Chat ID
Send message to your bot.
Open:
https://api.telegram.org/botTOKEN/getUpdates
Copy Chat ID.
13. n8n Workflow Architecture
Webhook
│
▼
Code Node
│
▼
AI Agent
│
┌─┴────────────┐
▼ ▼
Google Sheet Telegram
Alert
14. n8n Workflow Detailed Steps
Node 1
Webhook Node
POST
/webhook/evstation
Receives:
{
"voltage":230,
"current":10,
"power":2300
}
Node 2
Function Node
const power = $json.power;
let status = "Normal";
if(power > 2500)
{
status = "High Load";
}
return [{
json:{
power:power,
status:status
}
}]
Node 3
Google Sheets Node
Append Row.
Map:
Timestamp
Voltage
Current
Power
Status
Node 4
Telegram Node
Message:
⚡ EV Charging Alert
Power: {{$json.power}}
Status:
{{$json.status}}
15. n8n Workflow JSON
{
"name":"EV Station Workflow",
"nodes":[
{
"name":"Webhook"
},
{
"name":"AI Analysis"
},
{
"name":"Google Sheets"
},
{
"name":"Telegram"
}
]
}
This is a simplified structure. In production, export the workflow directly from n8n after configuration.
16. AI Power Consumption Prediction Logic
Dataset
Stored in Google Sheets:
Date
Time
Power
Energy
Temperature
Prediction Features
Current Power
Historical Power
Time of Day
Charging Duration
Simple Prediction Formula
Moving Average:
Prediction=
5
P
1
+P
2
+P
3
+P
4
+P
5
Example:
2200
2300
2400
2500
2600
Prediction:
2400W
Advanced AI
Use:
Linear Regression
Random Forest
XGBoost
LSTM Neural Networks
via Python or AI APIs connected through n8n.
17. Voice Notification Automation
Trigger Condition
Power > 2500W
n8n Flow
IF Node
│
▼
Generate Speech
│
▼
Telegram Send Voice
Voice Message
Warning.
Electric vehicle charging load
has exceeded the safe limit.
Current load is
2600 watts.
18. AI Agent Responsibilities
The AI agent can:
Monitor
Power
Voltage
Current
Energy
Decide
Overload detection
Peak demand prediction
Charger fault detection
Act
Notify user
Log event
Disable relay if dangerous
19. Automatic Relay Protection
If Power > 3000W
Relay OFF
Send Alert
Store Incident
Pseudo-code:
if(power > 3000)
{
digitalWrite(RELAY,LOW);
}
20. Cloud Dashboard Design
Dashboard Widgets
Gauge 1
Voltage
0–250V
Gauge 2
Current
0–32A
Gauge 3
Power
0–7000W
Chart
Daily Consumption
Chart
Weekly Consumption
21. Database Structure
ChargingLogs
------------
id
timestamp
voltage
current
power
energy
status
prediction
22. Future Enhancements
AI Features
Dynamic charging optimization
Peak tariff avoidance
Smart load balancing
Vehicle identification
Battery health estimation
IoT Features
RFID authentication
QR-code charging access
Solar integration
OCPP protocol support
Multi-station management
Mobile App
Flutter dashboard
Real-time monitoring
Push notifications
Usage analytics
23. Deployment Guide
Local Deployment
ESP32 connected to Wi-Fi
n8n running on PC or Raspberry Pi
Google Sheets cloud logging
ThingSpeak dashboard active
Cloud Deployment
Deploy n8n on:
n8n Cloud
AWS
Google Cloud
Microsoft Azure
24. Expected Output
Voltage : 228V
Current : 11A
Power : 2508W
Energy : 5.2kWh
AI Prediction:
2700W in next 30 minutes
Status:
High Load
Action:
Telegram Voice Alert Sent
Google Sheet Updated
ThingSpeak Updated
25. Project Outcome
This project demonstrates a complete Industry 4.0 and Smart EV Infrastructure solution combining:
ESP32 Edge Computing
IoT Cloud Monitoring
AI Agent Decision-Making
n8n Workflow Automation
Telegram Voice Notifications
Google Sheets Analytics
ThingSpeak Visualization
Predictive Energy Management
The architecture is scalable from a single charging point to a city-wide EV charging network with centralized AI monitoring and automated control.
AI Smart Door Lock System Using Face and Fingerprint Recognition
AI Smart Door Lock System Using Face & Fingerprint Recognition
AI-Powered ESP32 + Agentic IoT + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard
AI Smart Door Lock System Using Face & Fingerprint Recognition
AI-Powered ESP32 + Agentic IoT + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard
1. Project Overview
Project Title
AI Smart Door Lock System Using Face and Fingerprint Recognition with ESP32, n8n Automation, Telegram Voice Alerts, Google Sheets, and ThingSpeak Cloud Dashboard
Objective
Design and develop an intelligent smart door security system capable of:
Face Recognition Authentication
Fingerprint Authentication
Smart Lock Control
AI-based Access Decision Making
Real-time Cloud Monitoring
Telegram Voice Notifications
Automated Logging
AI Power Consumption Prediction
Agentic IoT Automation using n8n
2. System Architecture
+-------------------+
| Face Recognition |
| ESP32-CAM |
+---------+---------+
|
v
+-------------------+
| Authentication |
| Decision Engine |
+---------+---------+
|
v
+-------------------+
| Fingerprint |
| Sensor R307 |
+---------+---------+
|
v
+-------------------+
| ESP32 Controller |
+---------+---------+
|
+----------------------+
| |
v v
+----------------+ +----------------+
| Door Lock | | Cloud Services |
| Relay + Solenoid| +----------------+
+-------+--------+ |
| |
v v
Door Opens ThingSpeak
Google Sheets
Telegram Bot
n8n AI Agent
3. Features
Security Features
Multi-Factor Authentication
User must pass:
Face Recognition
Fingerprint Verification
before door unlocks.
Intruder Detection
If:
Unknown Face
Invalid Fingerprint
then:
Capture image
Send Telegram Alert
Store evidence in cloud
Voice Alert
Telegram receives:
"Warning! Unauthorized access attempt detected at Main Door."
4. Hardware Components List
Component Quantity
ESP32 Dev Board 1
ESP32-CAM 1
R307 Fingerprint Sensor 1
Relay Module 5V 1
Solenoid Door Lock 1
Buzzer 1
OLED Display (Optional) 1
PIR Motion Sensor 1
12V Adapter 1
LM2596 Buck Converter 1
Jumper Wires As Required
Breadboard/PCB 1
Magnetic Door Sensor 1
5. Circuit Connections
Fingerprint Sensor
R307 ESP32
VCC ---------> 5V
GND ---------> GND
TX ----------> GPIO16
RX ----------> GPIO17
Relay Module
Relay IN -----> GPIO26
Relay VCC ----> 5V
Relay GND ----> GND
Buzzer
Buzzer + ----> GPIO25
Buzzer - ----> GND
PIR Sensor
OUT ----------> GPIO27
VCC ----------> 5V
GND ----------> GND
ESP32-CAM
ESP32-CAM
|
WiFi
|
Cloud
Face recognition runs on ESP32-CAM.
6. Complete Flowchart
START
|
v
Initialize WiFi
|
v
Connect Cloud Services
|
v
Wait for Person
|
v
Capture Face
|
v
Face Match?
|
YES ---------------- NO
| |
v v
Scan Fingerprint Alert Intruder
| |
v |
Fingerprint Match? |
| |
YES ----- NO |
| | |
v v |
Unlock Alert |
Door User |
| | |
v v |
Log Data Log Data |
| | |
+--------+----------+
|
v
ThingSpeak
|
v
Google Sheet
|
v
Telegram
|
v
END
7. ESP32 Source Code Structure
Required Libraries
WiFi.h
HTTPClient.h
ArduinoJson.h
Adafruit_Fingerprint.h
ESP32Servo.h
WiFi Setup
const char* ssid = "YOUR_WIFI";
const char* password = "PASSWORD";
Telegram Configuration
String botToken="BOT_TOKEN";
String chatID="CHAT_ID";
ThingSpeak Configuration
String apiKey="THINGSPEAK_WRITE_KEY";
Door Lock Pin
#define LOCK_PIN 26
Unlock Function
void unlockDoor()
{
digitalWrite(LOCK_PIN,HIGH);
delay(5000);
digitalWrite(LOCK_PIN,LOW);
}
Fingerprint Verification
bool verifyFingerprint()
{
int id = finger.getImage();
if(id == FINGERPRINT_OK)
{
return true;
}
return false;
}
Send Telegram Alert
void sendTelegram(String msg)
{
HTTPClient http;
String url =
"https://api.telegram.org/bot"+
botToken+
"/sendMessage?chat_id="+
chatID+
"&text="+msg;
http.begin(url);
http.GET();
http.end();
}
Update ThingSpeak
void updateThingSpeak(
String status)
{
HTTPClient http;
String url=
"https://api.thingspeak.com/update?api_key="+
apiKey+
"&field1="+status;
http.begin(url);
http.GET();
http.end();
}
8. Face Recognition System
ESP32-CAM Operation
Step 1
Capture image.
Step 2
Run face detection.
Step 3
Compare with enrolled faces.
Step 4
Send result to ESP32.
KNOWN FACE
|
v
ESP32 Unlock Request
UNKNOWN FACE
|
v
Telegram Alert
9. AI Agent Using n8n
Purpose
AI Agent analyzes:
Entry patterns
Intruder attempts
Power consumption
Door usage frequency
n8n Workflow
ESP32 Webhook
|
v
Google Sheets
|
v
OpenAI Node
|
v
Decision Analysis
|
v
Telegram Alert
|
v
ThingSpeak Update
10. n8n Workflow Nodes
Node 1: Webhook
Receives data:
{
"user":"John",
"status":"Authorized",
"time":"2026-05-30 08:20"
}
Node 2: Google Sheets
Store:
Date
Time
User
Status
Node 3: AI Agent
Prompt:
Analyze today's door access records.
Detect suspicious behavior.
Predict energy consumption.
Generate summary.
Node 4: Telegram
Send report.
11. Example n8n Workflow JSON
{
"nodes": [
{
"name": "Webhook",
"type": "n8n-nodes-base.webhook"
},
{
"name": "Google Sheets",
"type": "n8n-nodes-base.googleSheets"
},
{
"name": "OpenAI",
"type": "@n8n/n8n-nodes-langchain.openAi"
},
{
"name": "Telegram",
"type": "n8n-nodes-base.telegram"
}
]
}
This is a simplified template; in deployment you would configure credentials, mappings, and error handling.
12. Telegram Bot Setup
Step 1
Open Telegram.
Search:
Telegram
Step 2
Search:
BotFather
Step 3
Create Bot
/newbot
Step 4
Copy Bot Token.
Example:
123456:ABCxyz
Step 5
Get Chat ID
https://api.telegram.org/botTOKEN/getUpdates
13. Voice Notification Automation
Event Trigger
Unauthorized Access
↓
n8n
↓
Text-to-Speech
↓
Telegram Voice Message
Voice Message Script
Alert!
Unknown person detected at the main entrance.
Please check immediately.
n8n Flow
Webhook
|
v
AI Agent
|
v
Google TTS
|
v
Telegram Voice
14. Google Sheets Integration
Columns:
Timestamp User Face Status Fingerprint Result
08:30 John Match Match Granted
ESP32 sends:
{
"user":"John",
"face":"match",
"finger":"match",
"access":"granted"
}
to n8n webhook.
n8n appends row automatically.
15. ThingSpeak Dashboard Setup
Create Channel
In ThingSpeak
Create fields:
Field1 = Door Status
Field2 = Authorized Access
Field3 = Unauthorized Access
Field4 = Power Consumption
Field5 = AI Risk Score
Dashboard Widgets
Gauge
Door Status
Line Chart
Power Usage
Counter
Access Count
Trend Graph
Unauthorized Attempts
16. AI Power Consumption Prediction
Data Inputs
Lock Activations
Camera Usage Time
WiFi Uptime
Fingerprint Scans
Formula
E=P×t
Where:
E = Energy (Wh)
P = Power (W)
t = Time (hours)
Sample Dataset
Day Power
1 5.2W
2 5.4W
3 5.8W
4 6.0W
AI predicts future usage and detects abnormal spikes.
17. AI Risk Scoring Logic
Known Face = 40 points
Known Fingerprint = 40 points
Normal Time Access = 20 points
Total:
100 = Safe
Risk Levels
Score Status
80-100 Safe
50-79 Warning
0-49 Threat
18. Database Design
Access Log Table
Field
ID
Timestamp
Face_ID
Finger_ID
Status
Power
RiskScore
19. Deployment Procedure
Phase 1
Hardware Assembly
Phase 2
Upload ESP32 Firmware
Phase 3
Enroll Faces
Phase 4
Enroll Fingerprints
Phase 5
Configure Wi-Fi
Phase 6
Create Telegram Bot
Phase 7
Deploy n8n Workflow
Phase 8
Connect Google Sheets
Phase 9
Connect ThingSpeak
Phase 10
Field Testing
20. Testing Scenarios
Test 1
Known Face + Known Fingerprint
Expected:
Door Opens
Telegram Log
Cloud Update
Test 2
Known Face + Wrong Fingerprint
Expected:
Access Denied
Alert Sent
Test 3
Unknown Face
Expected:
Buzzer ON
Image Capture
Telegram Voice Alert
21. Future Enhancements
Face recognition using Edge AI models (TensorFlow Lite Micro)
Liveness detection against photo spoofing
Visitor QR-code access
Mobile app control
Cloud-based user management
Voice assistant integration
Battery backup and solar charging
Multi-door enterprise deployment
Predictive maintenance analytics
AI anomaly detection using historical access logs
22. Expected Outcome
The final system provides:
✅ Face Recognition Security
✅ Fingerprint Authentication
✅ Smart Door Unlocking
✅ ESP32-Based IoT Control
✅ n8n Agentic Automation
✅ Telegram Text & Voice Alerts
✅ Google Sheets Logging
✅ ThingSpeak Dashboard Monitoring
✅ AI Risk Assessment
✅ Power Consumption Prediction
✅ Cloud-Based Smart Access Management
This architecture is suitable for academic projects, smart homes, offices, laboratories, hostels, and industrial access-control systems, while remaining low-cost and scalable.
AI Smart Baby Monitoring System with Cry and Motion Detection
AI Smart Baby Monitoring System with Cry and Motion Detection
ESP32 + AI Agent + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard
AI Smart Baby Monitoring System with Cry and Motion Detection
ESP32 + AI Agent + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard
1. Project Overview
This project is an AI-powered baby monitoring system that continuously monitors a baby's:
Crying sounds
Body movements
Environmental conditions
Sleep patterns
The system uses:
ESP32 as IoT Controller
Sound Sensor for Cry Detection
PIR Sensor for Motion Detection
ThingSpeak Cloud Dashboard
n8n Automation Workflow
Telegram Bot Notifications
Google Sheets Data Logging
AI Agent Logic for Smart Decision Making
Telegram Voice Alerts using Text-to-Speech
The system can:
✅ Detect crying baby
✅ Detect excessive movement
✅ Send instant Telegram alerts
✅ Send voice notifications
✅ Log all events into Google Sheets
✅ Visualize live data on ThingSpeak
✅ Predict baby discomfort trends using AI logic
2. System Architecture
+----------------------+
| Baby Room |
+----------------------+
|
|
+----------------------+
| Sensors |
|----------------------|
| Sound Sensor |
| PIR Motion Sensor |
| Temperature Sensor |
+----------------------+
|
|
+----------------------+
| ESP32 |
+----------------------+
|
WiFi
|
V
+----------------------+
| ThingSpeak Cloud |
+----------------------+
|
|
V
+----------------------+
| n8n Server |
+----------------------+
| | |
| | |
Telegram Google AI Agent
Alert Sheets
3. Hardware Components List
Component Quantity
ESP32 Dev Board 1
Sound Sensor KY-037 1
PIR Motion Sensor HC-SR501 1
DHT22 Temperature Sensor 1
Buzzer 1
LED Indicator 1
Breadboard 1
Jumper Wires Several
5V Adapter 1
WiFi Network 1
4. Working Principle
Cry Detection
Sound sensor continuously monitors sound level.
If Sound > Threshold
|
V
Cry Detected
ESP32 sends:
{
"event":"cry",
"sound":92
}
to ThingSpeak.
Motion Detection
PIR sensor detects movement.
Motion = HIGH
ESP32 sends:
{
"event":"motion",
"movement":"active"
}
AI Agent Analysis
n8n receives data.
Rules:
Cry + Motion
=
Baby Awake
Cry + No Motion
=
Possible Discomfort
No Cry + Motion
=
Restless Sleep
No Cry + No Motion
=
Sleeping
5. Circuit Schematic
Sound Sensor
Sound Sensor -> ESP32
VCC -> 3.3V
GND -> GND
AO -> GPIO34
PIR Sensor
PIR -> ESP32
VCC -> 5V
GND -> GND
OUT -> GPIO27
DHT22
DHT22 -> ESP32
VCC -> 3.3V
DATA -> GPIO4
GND -> GND
Buzzer
Buzzer -> GPIO18
LED
LED -> GPIO2
6. Pin Configuration
#define SOUND_PIN 34
#define PIR_PIN 27
#define DHT_PIN 4
#define BUZZER_PIN 18
#define LED_PIN 2
7. Flowchart
START
|
Initialize ESP32
|
Connect WiFi
|
Read Sound Sensor
|
Read Motion Sensor
|
Read Temperature
|
Sound > Threshold ?
| |
YES NO
| |
Cry Event Continue
|
Send Data
|
Motion Detected ?
| |
YES NO
| |
Motion Continue
|
Upload ThingSpeak
|
Trigger n8n
|
Send Telegram Alert
|
Log Google Sheet
|
Repeat
8. ESP32 Source Code
Install Libraries:
WiFi.h
HTTPClient.h
DHT.h
ThingSpeak.h
Main Code
#include
#include
#include
#include
char* ssid="YOUR_WIFI";
char* password="YOUR_PASSWORD";
unsigned long channelID = YOUR_CHANNEL_ID;
const char* writeAPIKey="YOUR_API_KEY";
WiFiClient client;
#define SOUND_PIN 34
#define PIR_PIN 27
#define DHT_PIN 4
DHT dht(DHT_PIN,DHT22);
void setup()
{
Serial.begin(115200);
pinMode(PIR_PIN,INPUT);
WiFi.begin(ssid,password);
while(WiFi.status()!=WL_CONNECTED)
{
delay(500);
}
ThingSpeak.begin(client);
dht.begin();
}
void loop()
{
int soundLevel=analogRead(SOUND_PIN);
int motion=digitalRead(PIR_PIN);
float temp=dht.readTemperature();
ThingSpeak.setField(1,soundLevel);
ThingSpeak.setField(2,motion);
ThingSpeak.setField(3,temp);
ThingSpeak.writeFields(channelID,writeAPIKey);
delay(15000);
}
9. ThingSpeak Setup
Create account:
ThingSpeak Official Platform
Create Channel
Fields:
Field1 = Sound Level
Field2 = Motion Status
Field3 = Temperature
Field4 = AI Risk Score
Dashboard Widgets
Add:
Gauge
Line Chart
Motion Indicator
Temperature Chart
Risk Score Chart
10. Telegram Bot Setup
Open Telegram
Search:
BotFather Telegram Bot Creation Guide
Commands:
/start
/newbot
Example:
BabyMonitorBot
Receive:
BOT_TOKEN
Get Chat ID:
https://api.telegram.org/botTOKEN/getUpdates
Save:
CHAT_ID
11. n8n Setup
Install n8n
n8n Official Website
Docker:
docker run -it --rm \
-p 5678:5678 \
-v ~/.n8n:/home/node/.n8n \
docker.n8n.io/n8nio/n8n
Open:
http://localhost:5678
12. n8n Workflow Logic
Webhook Trigger
|
V
Read Sensor Data
|
IF Cry?
|
YES
|
Telegram Alert
|
Google Sheet
|
ThingSpeak Update
|
AI Analysis
|
Voice Alert
13. n8n Workflow JSON Structure
{
"nodes":[
{
"name":"Webhook",
"type":"n8n-nodes-base.webhook"
},
{
"name":"IF Cry",
"type":"n8n-nodes-base.if"
},
{
"name":"Telegram",
"type":"n8n-nodes-base.telegram"
},
{
"name":"Google Sheets",
"type":"n8n-nodes-base.googleSheets"
}
]
}
Import this structure and configure credentials in n8n.
14. Google Sheets Integration
Create Sheet:
Baby Monitoring Log
Columns:
Timestamp Sound Motion Temperature Status
Connect using:
Google OAuth Credentials
in n8n.
Documentation:
Google Sheets API Documentation
15. AI Agent Decision Engine
Example rule engine:
if sound > 80 and motion == 1:
status = "Awake"
elif sound > 80 and motion == 0:
status = "Discomfort"
elif sound < 30 and motion == 1:
status = "Restless"
else:
status = "Sleeping"
16. AI Power Consumption Prediction Logic
Track:
Voltage
Current
Operating Hours
WiFi Usage
Formula:
Power = Voltage × Current
P=VI
Prediction:
daily_power = average_hourly_power * 24
monthly_power = daily_power * 30
AI Agent can estimate:
Battery remaining
Daily energy usage
Maintenance interval
17. Voice Notification Automation
Workflow:
Cry Detected
|
V
n8n
|
Google TTS
|
Generate MP3
|
Telegram Send Voice
Example message:
Attention.
Baby crying detected.
Immediate check recommended.
Useful services:
Google Text-to-Speech API
Telegram Send Voice Node
Documentation:
Google Cloud Text-to-Speech
18. AI Agent Enhancements
You can integrate:
OpenAI Platform
Ollama Local AI Models
LangChain Framework
Advanced analysis:
Analyze last 24 hours
Detect:
- Frequent crying
- Sleep interruptions
- Temperature abnormalities
Generate daily report
Example AI report:
Baby Sleep Score: 82%
Cry Events: 7
Motion Events: 24
Recommendation:
Check room temperature.
19. Deployment Guide
Stage 1
Build hardware.
Stage 2
Upload ESP32 code.
Stage 3
Verify WiFi connection.
Stage 4
Create ThingSpeak Channel.
Stage 5
Create Telegram Bot.
Stage 6
Install n8n.
Stage 7
Connect:
ESP32
↓
ThingSpeak
↓
n8n
↓
Telegram
↓
Google Sheets
Stage 8
Test Events
Clap near sensor → Cry event
Move in front of PIR → Motion event
Verify:
Telegram notification
Google Sheets entry
ThingSpeak graph update
20. Future Enhancements
AI Features
Real cry classification using TinyML
Baby face recognition
Sleep quality prediction
Fever prediction
Abnormal behavior detection
Hardware Upgrades
ESP32-CAM
MLX90614 IR thermometer
Microphone array
Battery backup
OLED display
Cloud Enhancements
Mobile app
Firebase integration
AWS IoT integration
Voice assistant support
Multi-room monitoring
Expected Project Outcome
The final system becomes a complete Agentic AI Baby Monitoring Platform capable of:
Real-time cry detection
Motion monitoring
Cloud analytics
AI decision making
Telegram text alerts
Telegram voice alerts
Google Sheets logging
ThingSpeak dashboard visualization
Power usage prediction
Daily baby activity reporting
This architecture is suitable for final-year engineering projects, IoT research prototypes, smart nursery deployments, and AI-enabled healthcare monitoring demonstrations.
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
Project Folder Structure
AI_Driver_Drowsiness_System/
│
├── index.php
├── assets/
│ ├── css/
│ ├── images/
│ └── js/
│
├── esp32/
│ └── esp32_code.ino
│
├── ai_model/
│ ├── train.py
│ └── drowsiness_model.h5
│
├── n8n/
│ └── workflow.json
│
└── docs/
└── project_report.pdf
This gives you a complete PHP-based project documentation webpage. For a final-year project, I would recommend expanding it into a multi-page professional PHP website with:
Home
About Project
Architecture Diagram
Components
Circuit Diagram
ESP32 Code
CNN Model
n8n Workflow
Telegram Integration
Google Sheets Dashboard
ThingSpeak Analytics
AI Agent Module
Power Prediction Module
Future Enhancements
Download Report (PDF)
which looks suitable for project submission and viva presentation.
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.
AI Smart Anti-Sleep Alarm System for Drivers
CNN + ESP32 + n8n + Telegram + Google Sheets + ThingSpeak
1. Project Description
This project detects driver drowsiness using a CNN-based AI model. When drowsiness is detected, ESP32 activates a buzzer and sends data to an n8n workflow. n8n automatically triggers Telegram alerts, voice notifications, Google Sheets logging, and ThingSpeak dashboard updates.
2. Components List
| Component | Quantity |
|---|---|
| ESP32 Dev Board | 1 |
| ESP32-CAM | 1 |
| OV2640 Camera | 1 |
| OLED SSD1306 | 1 |
| Active Buzzer | 1 |
| LED | 2 |
| Push Button | 1 |
| Battery Pack | 1 |
| Jumper Wires | As Required |
3. System Architecture
Camera | CNN Drowsiness Detection | ESP32 Controller | +--> Buzzer +--> OLED Display +--> n8n Webhook +--> Telegram +--> Google Sheets +--> ThingSpeak
4. Circuit Connections
OLED SSD1306 VCC -> 3.3V GND -> GND SCL -> GPIO22 SDA -> GPIO21 Buzzer + -> GPIO15 - -> GND LED + -> GPIO2 - -> 220 Ohm -> GND Button GPIO4
5. Flowchart
START | Initialize ESP32 | Connect WiFi | Capture Face | CNN Detection | Drowsy? | +----NO----> Continue Monitoring | YES | Activate Alarm | Send Data to n8n | Telegram Alert | Google Sheets | ThingSpeak | END
6. ESP32 Source Code
#include <WiFi.h>
#include <HTTPClient.h>
const char* ssid="YOUR_WIFI";
const char* password="PASSWORD";
String webhookURL =
"https://your-n8n-server/webhook/drowsy";
int buzzer = 15;
int led = 2;
void setup()
{
pinMode(buzzer,OUTPUT);
pinMode(led,OUTPUT);
WiFi.begin(ssid,password);
while(WiFi.status()!=WL_CONNECTED)
{
delay(500);
}
}
void loop()
{
int drowsyFlag = 1;
if(drowsyFlag)
{
digitalWrite(buzzer,HIGH);
digitalWrite(led,HIGH);
sendToN8N();
}
delay(5000);
}
7. CNN Training Code (Python)
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Conv2D
from tensorflow.keras.layers import Dense
from tensorflow.keras.layers import Flatten
model = Sequential()
model.add(Conv2D(32,(3,3),
activation='relu',
input_shape=(64,64,3)))
model.add(Flatten())
model.add(Dense(128,
activation='relu'))
model.add(Dense(1,
activation='sigmoid'))
model.compile(
optimizer='adam',
loss='binary_crossentropy',
metrics=['accuracy'])
model.save("drowsiness_model.h5")
8. n8n Workflow
Webhook | AI Agent | +--> Telegram Alert +--> Voice Notification +--> Google Sheets +--> ThingSpeak
9. Telegram Bot Setup
- Open Telegram
- Search @BotFather
- Create new bot using /newbot
- Copy API Token
- Add token in n8n Telegram node
10. Google Sheets Integration
| Date | Time | Driver | Status | Battery |
|---|---|---|---|---|
| 12-06-2026 | 10:30 AM | John | Drowsy | 78% |
11. ThingSpeak Dashboard
Field1 = Drowsiness Field2 = Battery Field3 = Eye Score Field4 = Alert Count
12. AI Power Consumption Prediction
Inputs Battery Voltage WiFi Usage Camera Runtime Alert Frequency Output Remaining Battery Life Power Consumption Forecast
13. Voice Notification Automation
Webhook | Text To Speech | Generate MP3 | Telegram Send Audio Voice Message: Warning! Driver drowsiness detected. Please stop and rest.
14. Future Enhancements
- YOLOv8 Face Detection
- TinyML on ESP32
- GPS Tracking
- Emergency SMS
- Accident Detection
- Fleet Monitoring Dashboard
- Predictive Fatigue Analytics
15. Deployment Steps
- Train CNN model
- Deploy model on PC/Raspberry Pi
- Connect ESP32
- Configure WiFi
- Setup n8n workflow
- Create Telegram Bot
- Connect Google Sheets
- Create ThingSpeak Dashboard
- Perform testing
- Deploy in vehicle
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
Subscribe to:
Posts (Atom)


















