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
Friday, 29 May 2026
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.
Subscribe to:
Post Comments (Atom)
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 ...
-
www.svsembedded.com SVSEMBEDDED svsembedded@gmail.com , CONTACT: 9491535690, 7842358459 ------------------------------------------...
-
Watch Video Demonstration Carefully Till End -- Temperature and Humidity Controller For Incubator Temperature and Humidity Controller For ...
-
Electronic KITS: DTDC Courier Proof Of Delivery Receipts - 2024 - 2023 - 2022 - 2021 - 2020 - 2019 - 2018 - 2017 - 2016...


No comments:
Post a Comment