Thursday, 18 June 2026

AI-Based Vehicle Speed Monitoring and Automatic Challan System

AI-Based Vehicle Speed Monitoring & Automatic Challan System Using ESP32 + AI Agent + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud
AI-Based Vehicle Speed Monitoring System

AI-Based Vehicle Speed Monitoring & Automatic Challan System

ESP32 + IoT + AI Agent + n8n + Telegram Voice Alerts + Google Sheets + ThingSpeak

1. Project Overview

This project is an AI-powered smart traffic monitoring system using ESP32, sensors, cloud dashboard, automation workflows, and Telegram alerts.

  • Vehicle Speed Detection
  • Automatic Challan Generation
  • Telegram Notifications
  • Voice Alerts
  • Google Sheets Logging
  • ThingSpeak Cloud Dashboard
  • AI Power Consumption Prediction

2. Components List

Component Quantity Purpose
ESP32 1 Main Controller
IR Sensors 2 Vehicle Detection
Buzzer 1 Alert Sound
OLED Display 1 Speed Display
LEDs 2 Status Indicators

3. Working Principle

Two IR sensors are placed at a fixed distance. When a vehicle crosses the first sensor, timer starts. When it crosses the second sensor, timer stops.

Speed Formula

Speed = Distance / Time

Speed(km/h) = (Distance / Time) × 3.6
    

4. Circuit Connections

Component ESP32 Pin
IR Sensor 1 GPIO 14
IR Sensor 2 GPIO 27
Buzzer GPIO 26
Green LED GPIO 25
Red LED GPIO 33

5. System Flowchart

START
   ↓
Initialize ESP32
   ↓
Connect WiFi
   ↓
Detect Vehicle
   ↓
Calculate Speed
   ↓
Speed > Limit?
   ↓
YES
   ↓
Send Alert to n8n
   ↓
Telegram Notification
   ↓
Voice Alert
   ↓
Google Sheets Update
   ↓
ThingSpeak Upload
   ↓
END
    

6. ESP32 Source Code

#include <WiFi.h>
#include <HTTPClient.h>

const char* ssid = "YOUR_WIFI";
const char* password = "YOUR_PASSWORD";

String webhook = "YOUR_N8N_WEBHOOK_URL";

#define SENSOR1 14
#define SENSOR2 27

unsigned long startTime;
unsigned long endTime;

float distanceMeters = 1.0;

bool trigger = false;

void setup() {

  Serial.begin(115200);

  pinMode(SENSOR1, INPUT);
  pinMode(SENSOR2, INPUT);

  WiFi.begin(ssid, password);

  while(WiFi.status() != WL_CONNECTED){
    delay(1000);
    Serial.println("Connecting...");
  }

  Serial.println("WiFi Connected");
}

void loop() {

  if(digitalRead(SENSOR1)==LOW && !trigger){

      startTime = millis();
      trigger = true;
  }

  if(digitalRead(SENSOR2)==LOW && trigger){

      endTime = millis();

      float timeSec = (endTime - startTime)/1000.0;

      float speed = (distanceMeters/timeSec)*3.6;

      Serial.println(speed);

      if(speed > 40){

          sendData(speed);
      }

      trigger = false;
  }
}

void sendData(float speed){

    HTTPClient http;

    http.begin(webhook);

    http.addHeader("Content-Type","application/json");

    String data = "{\"speed\":\""+String(speed)+"\"}";

    http.POST(data);

    http.end();
}

7. n8n Workflow

Webhook
   ↓
Check Speed Limit
   ↓
Telegram Alert
   ↓
Voice Notification
   ↓
Google Sheets Update
   ↓
ThingSpeak Upload

8. Telegram Bot Setup

  1. Open Telegram
  2. Search BotFather
  3. Create new bot using /newbot
  4. Copy Bot Token
  5. Get Chat ID

9. Google Sheets Integration

Time Speed Fine Status
10:30 AM 72 km/h ₹1000 Overspeed

10. ThingSpeak Cloud Dashboard

Upload sensor data to ThingSpeak cloud dashboard for:

  • Real-Time Speed Monitoring
  • Traffic Analytics
  • Power Consumption Tracking
  • Violation Statistics

11. AI Power Consumption Prediction

Predicted Power =
(sensor_time × current) +
(wifi_time × current)

AI predicts traffic load and controls ESP32 sleep mode for power optimization.

12. Voice Notification Automation

Telegram voice alerts are generated using:

  • Google Text-to-Speech
  • ElevenLabs API
Warning!
Overspeed vehicle detected.
Speed exceeded legal limit.
Automatic challan generated.

13. Automatic Challan Logic

Speed Range Fine Amount
40-60 km/h ₹500
60-80 km/h ₹1000
80+ km/h ₹2000

14. Future Enhancements

  • Number Plate Recognition
  • ESP32-CAM Integration
  • AI Traffic Prediction
  • Smart City Dashboard
  • Cloud AI Analytics
  • GPS Tracking

15. Deployment Guide

  1. Install sensors roadside
  2. Connect ESP32 to WiFi
  3. Deploy n8n workflow
  4. Configure Telegram bot
  5. Connect Google Sheets
  6. Setup ThingSpeak dashboard
  7. Test vehicle detection

16. Estimated Project Cost

Item Cost
ESP32 ₹500
Sensors ₹300
Display ₹250
Miscellaneous ₹500

Total Cost: ₹1500 - ₹2500

17. Conclusion

This AI-powered IoT project combines ESP32, automation workflows, Telegram notifications, AI analytics, and cloud dashboards to create an intelligent traffic monitoring and automatic challan system for smart cities.

AI-Based Vehicle Speed Monitoring System | ESP32 + AI + IoT + n8n

AI Smart Distance Monitoring and Predictive Object Detection System Using ESP32 and IoT

AI Smart Distance Monitoring and Predictive Object Detection System Using ESP32 + IoT + n8n + AI Agent + Telegram Voice Alerts + Google Sheets + ThingSpeak www.svsembedded.com SVSEMBEDDED svsembedded@gmail.com, CONTACT: 9491535690, 7842358459
<?php echo $title; ?>

AI Smart Distance Monitoring and Predictive Object Detection System

ESP32 + IoT + AI Agent + n8n + Telegram Voice Alerts + Google Sheets + ThingSpeak

1. Project Overview

This project continuously monitors object distance using an ultrasonic sensor connected to ESP32. The system uploads sensor data to ThingSpeak Cloud, logs records into Google Sheets, uses n8n automation workflows, and sends Telegram text and voice alerts.

Applications

  • Smart Parking
  • Industrial Safety
  • Intruder Detection
  • Warehouse Automation
  • Smart Manufacturing
  • Vehicle Collision Warning

2. Components Required

Component Quantity
ESP32 Development Board 1
HC-SR04 Ultrasonic Sensor 1
Breadboard 1
Jumper Wires 10
WiFi Router 1
Power Supply 1

3. Circuit Connections

HC-SR04      ESP32

VCC    ----> 5V
GND    ----> GND
TRIG   ----> GPIO5
ECHO   ----> GPIO18

Optional Buzzer:

+ ----> GPIO23
- ----> GND

4. System Architecture

Ultrasonic Sensor
        |
        V
      ESP32
        |
      WiFi
        |
 --------------------------------
 |             |               |
 V             V               V

ThingSpeak   n8n        Google Sheets

                |
                V

           AI Agent

                |
                V

      Telegram Voice Alerts

5. Flowchart

START

Initialize ESP32

Connect WiFi

Read Sensor Data

Calculate Distance

Upload To ThingSpeak

Send Data To n8n

AI Prediction

Distance < Threshold?

YES ----> Telegram Alert

Store Data In Google Sheets

Repeat

6. ESP32 Source Code

#include <WiFi.h>
#include <HTTPClient.h>

const char* ssid = "YOUR_WIFI";
const char* password = "YOUR_PASSWORD";

#define TRIG 5
#define ECHO 18

void setup()
{
  Serial.begin(115200);

  pinMode(TRIG, OUTPUT);
  pinMode(ECHO, INPUT);

  WiFi.begin(ssid,password);

  while(WiFi.status()!=WL_CONNECTED)
  {
      delay(1000);
  }
}

void loop()
{
 long duration;
 float distance;

 digitalWrite(TRIG,LOW);
 delayMicroseconds(2);

 digitalWrite(TRIG,HIGH);
 delayMicroseconds(10);

 digitalWrite(TRIG,LOW);

 duration = pulseIn(ECHO,HIGH);

 distance = duration * 0.034 / 2;

 Serial.println(distance);

 delay(15000);
}

7. ThingSpeak Setup

  1. Create ThingSpeak Account
  2. Create New Channel
  3. Add Fields:
    • Distance
    • Prediction
    • Power Consumption
  4. Copy Write API Key
  5. Insert API Key in ESP32 Code

8. Google Sheets Integration

Timestamp Distance Prediction Power Alert Status
10:00 40 cm Safe 1.2W No

9. Telegram Bot Setup

  1. Open Telegram
  2. Search BotFather
  3. Create Bot using /newbot
  4. Copy Bot Token
  5. Get Chat ID
  6. Use Token inside n8n Telegram Node

10. n8n Workflow

Webhook

Function Node

IF Node

AI Agent

Telegram

Google Sheets

ThingSpeak

11. AI Prediction Logic

40
35
30
25
20

Prediction:
Object Approaching
20
25
30
35
40

Prediction:
Object Moving Away

12. Power Consumption Prediction

Power = Voltage × Current

Voltage = 5V
Current = 0.24A

Power = 1.2W

AI predicts higher power usage when alert frequency increases.

13. Voice Alert Automation

Webhook
   |
AI Agent
   |
Text To Speech
   |
MP3 Voice
   |
Telegram Send Voice

Sample Alert:

Warning!
Object detected at 20 cm.
Immediate attention required.

14. AI Agent Decision Logic

Risk Level Action
Low Store Data Only
Medium Telegram Notification
High Telegram Voice Alert

15. ThingSpeak Dashboard Widgets

  • Distance Gauge
  • Distance Trend Graph
  • Power Prediction Graph
  • Alert Counter
  • Object Trend Analysis

16. Future Enhancements

  • ESP32-CAM Integration
  • Object Recognition
  • Human Detection
  • TensorFlow Lite Edge AI
  • LSTM Prediction Models
  • Smart City Deployment

17. Deployment Guide

  1. Assemble Hardware
  2. Upload ESP32 Firmware
  3. Configure ThingSpeak
  4. Configure Google Sheets
  5. Setup Telegram Bot
  6. Deploy n8n Workflow
  7. Test Distance Monitoring
  8. Verify Alerts and Dashboard

18. Expected Output

Distance : 18 cm

Prediction :
Object Approaching Rapidly

Risk :
HIGH

Action :
Telegram Voice Alert Sent

ThingSpeak Updated

Google Sheets Updated

Predicted Power :
1.6W
For a final-year engineering project, a better structure is usually a complete PHP project with: index.php (Dashboard) config.php (API keys) esp32_receiver.php (Webhook endpoint) telegram_alert.php google_sheets.php thingspeak_update.php ai_prediction.php voice_alert.php database.sql assets/css/style.css assets/js/dashboard.js This modular version looks more professional and is suitable for project submission and deployment.

Agentic AI Distance Analytics and Automated Data Logging System with Cloud Intelligence

www.svsembedded.com SVSEMBEDDED svsembedded@gmail.com, CONTACT: 9491535690, 7842358459
<?php echo $title; ?>

1. Project Overview

This project creates an AI-powered IoT monitoring platform using ESP32, HC-SR04 Ultrasonic Sensor, ThingSpeak Cloud, Google Sheets, Telegram Voice Notifications and n8n Automation.

  • Distance Measurement
  • Cloud Data Logging
  • AI Prediction Engine
  • Telegram Voice Alerts
  • Google Sheets Integration
  • ThingSpeak Dashboard

2. Components Required

Component Quantity
ESP32 Dev Board1
HC-SR04 Sensor1
Jumper WiresSeveral
Breadboard1
USB Cable1
WiFi Router1

3. Circuit Connections

HC-SR04 ESP32
VCC5V
GNDGND
TRIGGPIO5
ECHOGPIO18

4. Flowchart

START
  |
Initialize WiFi
  |
Read Distance
  |
Send to ThingSpeak
  |
Trigger n8n Webhook
  |
Store in Google Sheets
  |
AI Analysis
  |
Threshold Check
  |
Telegram Voice Alert
  |
Repeat

5. ESP32 Source Code

#include <WiFi.h>
#include <HTTPClient.h>

const char* ssid="YOUR_WIFI";
const char* password="YOUR_PASSWORD";

String apiKey="YOUR_THINGSPEAK_KEY";

#define TRIG 5
#define ECHO 18

void setup()
{
  Serial.begin(115200);

  pinMode(TRIG, OUTPUT);
  pinMode(ECHO, INPUT);

  WiFi.begin(ssid,password);

  while(WiFi.status()!=WL_CONNECTED)
  {
      delay(500);
  }
}

float getDistance()
{
  digitalWrite(TRIG,LOW);
  delayMicroseconds(2);

  digitalWrite(TRIG,HIGH);
  delayMicroseconds(10);

  digitalWrite(TRIG,LOW);

  long duration=pulseIn(ECHO,HIGH);

  return duration*0.034/2;
}

void loop()
{
  float distance=getDistance();

  HTTPClient http;

  String url =
  "https://api.thingspeak.com/update?api_key="
  + apiKey +
  "&field1=" + String(distance);

  http.begin(url);
  http.GET();
  http.end();

  delay(15000);
}

6. ThingSpeak Setup

  1. Create ThingSpeak Account
  2. Create New Channel
  3. Add Fields:
    • Distance
    • Prediction
    • Alert Status
  4. Copy Write API Key

7. Telegram Bot Setup

  1. Open Telegram
  2. Search BotFather
  3. Create New Bot
  4. Copy Bot Token
  5. Get Chat ID

8. Google Sheets Structure

Timestamp Distance Prediction Alert

9. n8n Workflow

Webhook
   |
Code Node
   |
Google Sheets
   |
IF Condition
   |
Telegram Alert

10. AI Prediction Logic

const current = $json.distance;

const prediction =
current + Math.random()*5;

return [{
  distance: current,
  prediction: prediction
}];

11. Telegram Voice Alert Logic

Distance Alert
      |
Generate TTS Audio
      |
Telegram Send Audio

Example Voice Message:

Warning.
Object detected at eight centimeters.
Please check immediately.

12. Power Consumption Prediction

Mode Current
WiFi Active 180mA
Processing 120mA
Deep Sleep 10µA
Battery Life =
Battery Capacity / Average Current

13. Future Enhancements

  • Multi-Sensor Integration
  • Temperature Monitoring
  • Humidity Monitoring
  • Gas Detection
  • ESP32 Camera AI Vision
  • Digital Twin Dashboard
  • Edge AI Inference

14. Deployment Architecture

ESP32
 ↓
ThingSpeak
 ↓
n8n
 ↓
Google Sheets
 ↓
Telegram

15. Expected Output

Distance = 24.6 cm

Prediction = 25.1 cm

Status = NORMAL
This PHP file can be saved as index.php, hosted on a PHP server (XAMPP, WAMP, LAMP, or Apache), and viewed as a complete project documentation webpage. For a professional final-year project, you can further split it into: index.php (dashboard) components.php circuit.php esp32_code.php n8n_workflow.php thingspeak_setup.php telegram_setup.php deployment_guide.php with Bootstrap styling, navigation menus, downloadable source code sections, and an admin dashboard layout.

AI-Driven Smart Energy Consumption Monitoring and Load Forecasting System Using ESP32

www.svsembedded.com SVSEMBEDDED svsembedded@gmail.com, CONTACT: 9491535690, 7842358459 AI-Driven Smart Energy Consumption Monitoring and Load Forecasting System Using ESP32 + Agentic AI + n8n + Telegram Voice Alerts + Google Sheets + ThingSpeak
<?php echo $title; ?>

AI-Driven Smart Energy Consumption Monitoring and Load Forecasting System

Project Overview

This project develops an intelligent IoT-based energy monitoring and forecasting system using ESP32, ACS712 current sensor, ZMPT101B voltage sensor, ThingSpeak cloud, Google Sheets, Telegram Bot, n8n automation, and AI-based prediction algorithms.

Objectives

  • Monitor voltage, current, power and energy consumption.
  • Store data in ThingSpeak and Google Sheets.
  • Predict future energy demand using AI.
  • Generate Telegram text and voice alerts.
  • Provide autonomous Agentic AI decision-making.

Hardware Components

Component Quantity
ESP32 Dev Board1
ACS712 Current Sensor1
ZMPT101B Voltage Sensor1
Relay Module1
OLED Display1
Breadboard1
Jumper WiresSeveral
5V Adapter1

System Architecture

Electrical Load
      |
ACS712 + ZMPT101B
      |
     ESP32
      |
-------------------------------------
|            |            |
ThingSpeak   n8n     Google Sheets
                 |
           AI Forecast
                 |
          Telegram Alerts
                 |
         Voice Notifications

Circuit Connections

Sensor ESP32 Pin
ACS712 OUT GPIO34
ZMPT101B OUT GPIO35
Relay IN GPIO26
OLED SDA GPIO21
OLED SCL GPIO22

Project Flowchart

START
 |
Initialize ESP32
 |
Connect WiFi
 |
Read Sensors
 |
Calculate Power
 |
Upload ThingSpeak
 |
Send Data to n8n
 |
Store Google Sheets
 |
AI Prediction
 |
Threshold Check
 |
Telegram Alert
 |
END

ESP32 Source Code

#include <WiFi.h>
#include <HTTPClient.h>

const char* ssid="YOUR_WIFI";
const char* password="YOUR_PASSWORD";

int currentPin=34;
int voltagePin=35;

float voltage,current,power;

void setup()
{
 Serial.begin(115200);

 WiFi.begin(ssid,password);

 while(WiFi.status()!=WL_CONNECTED)
 {
   delay(500);
 }

 Serial.println("Connected");
}

void loop()
{
 int currentRaw=analogRead(currentPin);
 int voltageRaw=analogRead(voltagePin);

 current=currentRaw*0.01;
 voltage=voltageRaw*0.1;

 power=voltage*current;

 delay(15000);
}

ThingSpeak Setup

  1. Create ThingSpeak account.
  2. Create New Channel.
  3. Add Fields:
    • Voltage
    • Current
    • Power
    • Energy
  4. Copy API Key.
  5. Paste API Key into ESP32 code.

Google Sheets Integration

Date Time Voltage Current Power Energy Prediction

Telegram Bot Setup

  1. Open BotFather.
  2. Create Bot using /newbot.
  3. Copy Bot Token.
  4. Get Chat ID.
  5. Configure Telegram Node in n8n.

n8n Workflow

Webhook
  |
Google Sheets
  |
AI Prediction
  |
IF Condition
  |
Telegram Alert

AI Prediction Logic

Moving Average

Forecast =
(P1 + P2 + P3 + P4 + P5) / 5

Advanced Models

  • Linear Regression
  • Random Forest
  • XGBoost
  • LSTM Neural Network

Voice Notification Logic

Power > Threshold
        |
Generate Speech
        |
Telegram Voice Alert

Agentic AI Functions

  • Monitor Energy Usage
  • Detect Anomalies
  • Predict Future Demand
  • Trigger Alerts
  • Control Relay Automatically

Database Structure

Field Name
Timestamp
Voltage
Current
Power
Energy
Predicted_Load
Alert_Status
Action_Taken

Future Enhancements

  • TinyML on ESP32
  • Solar Energy Integration
  • Battery Monitoring
  • Multi-Room Monitoring
  • Flutter Mobile App
  • Predictive Maintenance

Expected Results

Metric Value
Monitoring Accuracy95-98%
Forecast Accuracy85-95%
Cloud Update15 sec
Alert Delay< 5 sec

Conclusion

This project integrates ESP32 IoT sensing, cloud analytics, Google Sheets logging, AI forecasting, n8n workflow automation, Telegram voice alerts, and Agentic AI decision-making into a complete Smart Energy Management System.

This produces a complete web-based project documentation page (index.php) that can be hosted on a PHP server such as Apache, XAMPP, WAMP, or a Linux LAMP stack. For a final-year project, I would recommend expanding it into a multi-page PHP application with: index.php (dashboard) sensor_data.php prediction.php telegram_alerts.php thingspeak_integration.php n8n_workflow.php database.sql config.php api/esp32_receiver.php so it functions as a real smart energy monitoring platform rather than only a documentation page.

Friday, 12 June 2026

Intelligent AI Smart Helmet with Alcohol Detection, Accident Prediction and Emergency Response Automation

Intelligent AI Smart Helmet with Alcohol Detection, Accident Prediction & Emergency Response Automation ESP32 + IoT + AI Agent + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak
<?php echo $title; ?>

Intelligent AI Smart Helmet

Alcohol Detection | Accident Prediction | Emergency Response Automation

1. Project Overview

This project develops an AI-powered smart helmet using ESP32, MQ3 alcohol sensor, MPU6050, GPS, ThingSpeak cloud, n8n automation, Google Sheets and Telegram alerts.

2. Objectives

  • Alcohol Detection
  • Helmet Wear Detection
  • Accident Detection
  • Accident Prediction
  • GPS Tracking
  • Telegram Alerts
  • Voice Notifications
  • Google Sheets Logging
  • ThingSpeak Dashboard
  • AI Agent Safety Analysis

3. Components List

Component Quantity
ESP321
MQ3 Alcohol Sensor1
MPU6050 Sensor1
NEO-6M GPS Module1
IR Helmet Sensor1
Buzzer1
Battery Pack1
TP4056 Charger1

4. System Architecture

Helmet Sensors
      |
      V
    ESP32
      |
      V
 ThingSpeak Cloud
      |
      V
   n8n Workflow
      |
      V
 AI Agent Analysis
      |
 --------------------
 |         |        |
 V         V        V
Telegram  Sheets  Voice Alerts

5. Circuit Connections

MQ3 AO      -> GPIO34
MPU6050 SDA -> GPIO21
MPU6050 SCL -> GPIO22
GPS TX      -> GPIO16
GPS RX      -> GPIO17
IR Sensor   -> GPIO25
Buzzer      -> GPIO27

6. Accident Detection Formula

a = sqrt(x² + y² + z²)

IF a > 3g
THEN Accident Detected

7. AI Risk Prediction

Parameter Weight
Hard Braking20
High Tilt25
High Speed20
Sudden Turns20
Alcohol15
Risk Score = Σ(Wi × Fi)

If Risk > 70
Send Warning Alert

8. Flowchart Logic

START

Initialize Sensors

Read Helmet Sensor

Helmet Worn?

NO --> Alert

YES

Read MQ3

Alcohol?

YES --> Alert

NO

Read MPU6050

Calculate Risk

Risk > 70 ?

YES --> Warning

NO

Accident?

YES --> Emergency Alert

NO

Upload Data

Repeat

9. ESP32 Sample Code

float alcoholValue;
float acceleration;
float riskScore;

void loop()
{
  alcoholValue = analogRead(34);

  readMPU();

  riskScore = calculateRisk();

  if(alcoholValue > 2000)
  {
      sendAlert();
  }

  if(acceleration > 3.0)
  {
      sendEmergency();
  }

  uploadThingSpeak();

  delay(1000);
}

10. ThingSpeak Fields

FieldDescription
Field1Alcohol Level
Field2Acceleration
Field3Risk Score
Field4Latitude
Field5Longitude
Field6Helmet Status

11. n8n Workflow

Webhook
   |
   V
Receive ESP32 Data
   |
   V
AI Agent
   |
  / \
 /   \
V     V

Google Sheets
Telegram Alerts

12. Telegram Bot Setup

  1. Open Telegram
  2. Search BotFather
  3. Create New Bot
  4. Get Bot Token
  5. Add Token to n8n Telegram Node

13. Voice Notification Automation

ESP32
  |
  V
n8n
  |
  V
AI Text
  |
  V
Text To Speech
  |
  V
Telegram Voice Alert

14. Emergency Response Workflow

  1. Detect Accident
  2. Get GPS Coordinates
  3. Generate AI Message
  4. Send Telegram Alert
  5. Send Voice Message
  6. Update Google Sheet
  7. Update ThingSpeak Dashboard

15. AI Power Prediction

Power = Voltage × Current

P = V × I

Battery Life =
Battery Capacity / Current Draw

AI predicts remaining battery life using previous sensor, WiFi and GPS usage patterns.

16. Future Enhancements

  • TinyML Accident Prediction
  • Driver Fatigue Detection
  • Heart Rate Monitoring
  • Voice Assistant
  • AWS IoT Integration
  • Firebase Dashboard
  • Camera Based Safety Monitoring

17. Expected Outcomes

  • Alcohol Detection
  • Accident Detection
  • Accident Prediction
  • GPS Tracking
  • AI Safety Analysis
  • Telegram Voice Alerts
  • Google Sheets Logging
  • ThingSpeak Dashboard
  • Emergency Response Automation
For a complete academic project, I can also generate: index.php (dashboard homepage) config.php (database configuration) api.php (ESP32 data receiver API) save_data.php (MySQL storage) dashboard.php (live charts) telegram_alert.php (Telegram notifications) predict_ai.php (AI risk prediction module) database.sql (MySQL tables) Full project folder structure ready for XAMPP deployment.

AI-Based Railway Track Fault Prediction and Autonomous Alert System Using Raspberry Pi Pico, GPS and Computer Vision

AI-Based Railway Track Fault Prediction and Autonomous Alert System Using Raspberry Pi Pico + ESP32 + GPS + Computer Vision + Agentic AI + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud
<?php echo $pageTitle; ?>

AI-Based Railway Track Fault Prediction and Autonomous Alert System

Using Raspberry Pi Pico, ESP32, GPS, Computer Vision, AI Agent, n8n, Telegram Voice Alerts, Google Sheets & ThingSpeak

1. Project Overview

This project provides an intelligent railway monitoring system capable of detecting track cracks, obstacles, abnormal vibrations, and rail misalignment using sensors, computer vision, GPS tracking, cloud computing, and artificial intelligence.

The collected data is transmitted through ESP32 to cloud platforms where AI models predict risk levels and automatically generate alerts through Telegram voice notifications.

2. Objectives

  • Detect railway track cracks automatically.
  • Monitor vibration and temperature continuously.
  • Track exact GPS location of faults.
  • Predict maintenance requirements using AI.
  • Send automatic Telegram alerts.
  • Store data in Google Sheets and ThingSpeak.
  • Provide real-time cloud dashboard monitoring.

3. Components Required

Component Quantity Purpose
Raspberry Pi Pico W 1 Data Processing
ESP32 1 WiFi Communication
NEO-6M GPS 1 Location Tracking
MPU6050 1 Vibration Detection
DHT22 1 Temperature Monitoring
HC-SR04 1 Obstacle Detection
ESP32-CAM 1 Computer Vision
18650 Battery 1 Power Supply

4. System Architecture

Railway Track
      |
      V
Sensors + Camera
      |
      V
Raspberry Pi Pico
      |
      V
ESP32 Gateway
      |
      V
ThingSpeak Cloud
Google Sheets
      |
      V
n8n Automation
      |
      V
AI Agent
      |
      V
Telegram Voice Alert
      |
      V
Control Room

5. Working Principle

  1. Initialize all sensors and modules.
  2. Collect vibration data from MPU6050.
  3. Read temperature using DHT22.
  4. Detect obstacles using ultrasonic sensor.
  5. Capture railway track images.
  6. Perform AI image analysis.
  7. Detect cracks and faults.
  8. Read GPS coordinates.
  9. Calculate risk score.
  10. Upload information to cloud.
  11. Store records in Google Sheets.
  12. Generate Telegram notifications.
  13. Send voice alerts to railway officials.

6. Circuit Connections

MPU6050

VCC -> 3.3V
GND -> GND
SDA -> GPIO21
SCL -> GPIO22

GPS NEO-6M

VCC -> 3.3V
GND -> GND
TX -> GPIO16
RX -> GPIO17

DHT22

DATA -> GPIO4
VCC -> 3.3V
GND -> GND

HC-SR04

TRIG -> GPIO5
ECHO -> GPIO18

IR Sensor

OUT -> GPIO15
VCC -> 3.3V
GND -> GND

7. Flowchart


START

↓

Initialize System

↓

Collect Sensor Data

↓

Capture Image

↓

AI Detection

↓

Fault Found?

YES ------------------- NO
 |                       |
 V                       |
Get GPS                  |
 |                       |
 V                       |
Upload Cloud             |
 |                       |
 V                       |
AI Risk Prediction       |
 |                       |
 V                       |
Telegram Alert           |
 |                       |
 V                       |
Voice Notification       |
 |                       |
 V                       |
END <--------------------

8. Computer Vision Module

YOLOv8 Nano model is used for crack detection and obstacle identification.

pip install ultralytics

yolo detect train \
data=rail.yaml \
model=yolov8n.pt \
epochs=100

Output Model: best.pt

9. ESP32 Source Code

#include <WiFi.h>
#include <HTTPClient.h>

const char* ssid="WiFi_Name";
const char* password="WiFi_Password";

void setup()
{
 Serial.begin(115200);

 WiFi.begin(ssid,password);

 while(WiFi.status()!=WL_CONNECTED)
 {
   delay(1000);
 }
}

void loop()
{
 HTTPClient http;

 http.begin("https://api.thingspeak.com/update");

 http.GET();

 http.end();

 delay(15000);
}

10. ThingSpeak Setup

  • Create ThingSpeak account.
  • Create channel.
  • Add fields:
    • Temperature
    • Vibration
    • Crack Status
    • GPS Latitude
    • GPS Longitude
    • Risk Score
  • Copy API Key.
  • Use API key in ESP32 code.

11. Google Sheets Integration

Timestamp Temperature Vibration Risk Score
10:00 40°C 8.2 92%

12. Telegram Bot Setup

  1. Open Telegram.
  2. Search BotFather.
  3. Create new bot.
  4. Get Bot Token.
  5. Configure Telegram API.
  6. Connect n8n workflow.

13. n8n Workflow


Webhook

↓

ThingSpeak Data

↓

AI Agent

↓

Risk > 70 ?

↓

Telegram Alert

↓

Voice Generator

↓

Google Sheets Update

↓

Dashboard Update

14. AI Risk Prediction Logic

Risk Score = 0.4 × Crack + 0.3 × Vibration + 0.2 × Temperature + 0.1 × Alignment

Risk Score Status
0 - 30 Safe
31 - 60 Warning
61 - 80 High Risk
81 - 100 Critical

15. Telegram Voice Alert


WARNING!

Railway Track Crack Detected

Latitude : 17.3850
Longitude: 78.4867

Risk Score: 92%

Immediate Inspection Required

16. Future Enhancements

  • Edge AI Deployment
  • LoRa Communication
  • 4G/5G Backup Network
  • Digital Twin Dashboard
  • Automatic Signal Control
  • Predictive Maintenance Analytics
  • Railway Control Center Integration

17. Deployment Guide

Prototype Stage

  • Single Track Section
  • One ESP32 Node
  • One Camera Module

Pilot Deployment

  • 1-5 km Railway Section
  • Solar Powered Sensor Nodes
  • Cloud Monitoring

Production Deployment

  • Sensor Nodes Every 500 m
  • Central AI Server
  • 24/7 Monitoring Dashboard

18. Conclusion

The AI-Based Railway Track Fault Prediction and Autonomous Alert System provides intelligent monitoring, real-time fault detection, predictive maintenance, cloud analytics, GPS tracking, and automated Telegram voice alerts. The solution enhances railway safety and minimizes accident risks through continuous monitoring and AI-driven decision-making.

Save the file as railway_fault_prediction.php, place it in your PHP server folder (e.g., XAMPP htdocs), and open: http://localhost/railway_fault_prediction.php This will display the complete project documentation as a professional PHP web page.

AI-Powered Smart Attendance Management System with RFID, ESP32 and Automated Workflow Intelligence

AI-Powered Smart Attendance Management System RFID + ESP32 + Agentic AI + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard
AI-Powered Smart Attendance Management System

AI-Powered Smart Attendance Management System

RFID + ESP32 + Agentic AI + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard


1. Project Overview

This project is an intelligent attendance monitoring system that combines:

  • RFID-based attendance tracking
  • ESP32 IoT controller
  • Cloud data storage
  • AI-powered analytics
  • n8n workflow automation
  • Telegram voice notifications
  • Google Sheets database
  • ThingSpeak IoT dashboard
  • Predictive attendance and power consumption analysis

The system automatically:

  1. Detects RFID card scans.
  2. Verifies student/employee identity.
  3. Uploads attendance to cloud.
  4. Updates Google Sheets.
  5. Updates ThingSpeak dashboard.
  6. Triggers n8n workflows.
  7. Generates Telegram alerts.
  8. Sends voice notifications.
  9. Uses AI to predict attendance trends and power consumption.
  10. Creates intelligent reports.

2. System Architecture

+--------------------+
| RFID Card / Tag    |
+---------+----------+
          |
          v
+--------------------+
| RC522 RFID Reader  |
+---------+----------+
          |
          v
+--------------------+
| ESP32 Controller   |
+---------+----------+
          |
 WiFi Data Upload
          |
          v
+------------------------------+
| n8n Automation Server        |
+------------------------------+
      |       |         |
      |       |         |
      v       v         v
Google   Telegram   ThingSpeak
Sheets   Alerts      Dashboard
      |
      v
AI Analytics Engine
      |
      v
Attendance Prediction
Power Prediction
Reports

3. Features

Attendance Management

  • RFID card authentication
  • Real-time attendance logging
  • Duplicate scan prevention
  • Entry/Exit monitoring

AI Features

  • Attendance prediction
  • Absentee prediction
  • Occupancy forecasting
  • Power consumption prediction
  • Behavioral analysis

Automation Features

  • Auto attendance logging
  • Auto report generation
  • Voice alerts
  • Daily summaries
  • Weekly summaries

Cloud Features

  • Remote monitoring
  • Dashboard visualization
  • Historical data storage
Since your document is very large (25 sections with code blocks, tables, flowcharts, etc.), the practical approach is to paste the remaining sections exactly unchanged inside the
...
area. Save the file as: smart_attendance_system.php and run it on: Apache (XAMPP/WAMP/LAMP) or PHP Built-in Server php -S localhost:8000 Then open: http://localhost:8000/smart_attendance_system.php to view the complete documentation as a web page.

Thursday, 11 June 2026

Agentic AI Climate Monitoring and Smart Environmental Decision System with Telegram Voice Assistant

Agentic AI Climate Monitoring and Smart Environmental Decision System ESP32 + Sensors + AI Agent + n8n Automation + Telegram Voice Assistant + Google Sheets + ThingSpeak Cloud Dashboard
<?php echo $title; ?>

Agentic AI Climate Monitoring and Smart Environmental Decision System

Project Overview

This project combines ESP32, IoT sensors, AI decision-making, n8n automation, Telegram voice notifications, Google Sheets logging, and ThingSpeak cloud analytics.

System Architecture

Sensors
   |
   V
ESP32
   |
WiFi
   |
+-------------+
| ThingSpeak  |
+-------------+
       |
       V
+-------------+
| n8n AI      |
+-------------+
       |
+------+------+
|             |
V             V
Google     Telegram
Sheets     Voice Alerts

Hardware Components

Component Quantity
ESP32 Dev Board 1
DHT22 Sensor 1
MQ135 Gas Sensor 1
LDR Sensor 1
Soil Moisture Sensor 1

Circuit Connections

DHT22
VCC  -> 3.3V
GND  -> GND
DATA -> GPIO4

MQ135
AO   -> GPIO34

LDR
OUT  -> GPIO35

Soil Moisture
AO   -> GPIO32

Flowchart

Start
 |
Initialize ESP32
 |
Connect WiFi
 |
Read Sensors
 |
Send to ThingSpeak
 |
Trigger n8n
 |
AI Analysis
 |
Google Sheets
 |
Telegram Alert
 |
Voice Notification
 |
Repeat

ESP32 Source Code

#include <WiFi.h>
#include <HTTPClient.h>
#include "DHT.h"

#define DHTPIN 4
#define DHTTYPE DHT22

DHT dht(DHTPIN,DHTTYPE);

void setup()
{
  Serial.begin(115200);
  dht.begin();
}

void loop()
{
  float temp=dht.readTemperature();
  float hum=dht.readHumidity();

  int air=analogRead(34);
  int light=analogRead(35);
  int soil=analogRead(32);

  // Upload data

  delay(30000);
}

ThingSpeak Integration

1. Create ThingSpeak Account
2. Create Channel
3. Add Fields
4. Copy API Key
5. Insert API Key in ESP32 Code

Google Sheets Integration

Timestamp Temperature Humidity Air Quality Light Soil Moisture Status

n8n Workflow

Webhook
  |
Function
  |
Google Sheets
  |
AI Analysis
  |
Telegram Alert
  |
Voice Message

AI Decision Logic

Temperature > 40°C
  => Heat Alert

Humidity < 25%
  => Dry Alert

Air Quality > 2500
  => Pollution Alert

Soil Moisture < 800
  => Irrigation Required

Power Consumption Prediction

Power =
(Fan Hours × 75W)
+
(Pump Hours × 120W)
+
(Light Hours × 20W)

Telegram Voice Alerts

The AI Agent generates text alerts and converts them to speech using TTS services such as OpenAI TTS, Google TTS, or ElevenLabs. The generated MP3 file is automatically sent to Telegram.

Future Enhancements

  • Machine Learning Forecasting
  • Automatic Irrigation Control
  • Smart Greenhouse Automation
  • LoRaWAN Support
  • Multi-language Voice Assistant

Deployment

Deploy n8n using Docker, AWS, Google Cloud, or Azure. ESP32 continuously streams sensor data to cloud services.

For a complete project submission, I would recommend splitting it into: /project │ ├── index.php ├── dashboard.php ├── config.php ├── esp32_code.ino ├── n8n_workflow.json ├── assets/ │ ├── style.css │ ├── flowchart.png │ ├── circuit_diagram.png │ ├── docs/ │ ├── project_report.pdf │ ├── user_manual.pdf │ └── database/ └── climate_monitor.sql This structure looks professional for final-year engineering, IoT, AI, and smart agriculture project submissions.

AI Agent Air Quality Intelligence Platform with Automated Voice Alerts and Predictive Pollution Analysis

AI Agent Air Quality Intelligence Platform ESP32 + Air Quality Sensors + n8n Automation + AI Agent + Telegram Voice Alerts + Google Sheets + ThingSpeak Dashboard
<?php echo $title; ?>

AI Agent Air Quality Intelligence Platform

ESP32 + AI Agent + n8n + Telegram Voice Alerts + Google Sheets + ThingSpeak

Project Overview

This project develops an AI-powered Air Quality Monitoring System using ESP32, MQ135 Air Quality Sensor, DHT22, ThingSpeak Cloud, n8n Automation, Telegram Voice Alerts, Google Sheets Logging, and Predictive Analytics.

  • Real-Time Air Quality Monitoring
  • Cloud Dashboard Visualization
  • AI-Based Pollution Prediction
  • Telegram Voice Notifications
  • Google Sheets Data Logging
  • Agentic Decision Making

System Architecture

MQ135 + DHT22
       |
       V
     ESP32
       |
       V
    WiFi Cloud
       |
       V
   ThingSpeak
       |
       V
       n8n
   /    |    \
Sheets Telegram AI
            |
            V
      Voice Alerts

Components List

Component Quantity
ESP321
MQ135 Sensor1
DHT22 Sensor1
OLED Display1
Breadboard1
Jumper Wires20
WiFi Router1

Circuit Connections

MQ135

VCC  -> 5V
GND  -> GND
AOUT -> GPIO34

DHT22

VCC  -> 3.3V
GND  -> GND
DATA -> GPIO4

OLED

VCC -> 3.3V
GND -> GND
SDA -> GPIO21
SCL -> GPIO22

Flowchart

Start
 |
Initialize ESP32
 |
Connect WiFi
 |
Read Sensors
 |
Calculate AQI
 |
Upload to ThingSpeak
 |
Trigger n8n
 |
AI Analysis
 |
High Pollution?
 / \
Yes No
 |   |
Send Alert
 |
Voice Notification
 |
Store in Google Sheets
 |
Loop

AQI Classification

AQI Status
0-50Good
51-100Moderate
101-150Unhealthy for Sensitive Groups
151-200Unhealthy
201-300Very Unhealthy
301+Hazardous

ESP32 Sample Code

#include <WiFi.h>
#include <HTTPClient.h>

const char* ssid="YOUR_WIFI";
const char* password="YOUR_PASSWORD";

void setup()
{
 Serial.begin(115200);

 WiFi.begin(ssid,password);

 while(WiFi.status()!=WL_CONNECTED)
 {
   delay(500);
 }
}

void loop()
{
 int airValue=analogRead(34);

 HTTPClient http;

 String url=
 "https://api.thingspeak.com/update?api_key=KEY"
 "&field1="+String(airValue);

 http.begin(url);
 http.GET();
 http.end();

 delay(60000);
}

ThingSpeak Setup

  1. Create ThingSpeak Account
  2. Create New Channel
  3. Add AQI Field
  4. Copy Write API Key
  5. Paste into ESP32 Code

Telegram Bot Setup

  1. Open Telegram
  2. Search BotFather
  3. Create New Bot
  4. Copy Bot Token
  5. Get Chat ID
  6. Configure in n8n

n8n Workflow

Webhook
  |
IF AQI > 150
  |
OpenAI Analysis
  |
Google Sheets
  |
Telegram Alert
  |
Text-to-Speech
  |
Telegram Voice Message

AI Prediction Logic

Moving Average

Predicted AQI =
(AQI1+AQI2+AQI3+AQI4+AQI5)/5

Linear Regression

AQI = m*x + c

Advanced AI Models

  • Random Forest
  • XGBoost
  • LSTM
  • Time Series Forecasting

Voice Notification Message

Warning!

Air quality is unhealthy.

Current AQI: 185

Predicted AQI: 230

Avoid outdoor activities.

Google Sheets Columns

Timestamp AQI Temperature Humidity Prediction Status

Future Enhancements

  • Machine Learning Forecasting
  • Solar-Powered ESP32
  • LoRaWAN Communication
  • Mobile Application
  • GIS Air Pollution Maps
  • Industrial Deployment
  • Smart City Integration

Estimated Cost

Item Cost (₹)
ESP32500
MQ135250
DHT22250
OLED250
Accessories200
Total 1450
For a professional final-year project, you could further split this into: index.php (dashboard) esp32_code.php thingspeak_setup.php telegram_setup.php n8n_workflow.php ai_prediction.php deployment_guide.php and add Bootstrap, charts, login authentication, live ThingSpeak data fetching, and downloadable PDF documentation.

Agentic AI Smart Grid Load Analytics and Real-Time Energy Optimization System Using ESP32

Agentic AI Smart Grid Load Analytics and Real-Time Energy Optimization System Using ESP32, n8n, Telegram Voice Alerts, Google Sheets & ThingSpeak
<?php echo $title; ?>

Agentic AI Smart Grid Load Analytics

ESP32 + n8n + AI Agent + Telegram Voice Alerts + Google Sheets + ThingSpeak

1. Project Overview

This project provides a real-time smart grid energy monitoring and optimization system using ESP32, AI-powered analytics, n8n workflow automation, Telegram alerts, Google Sheets logging, and ThingSpeak cloud visualization.

2. System Architecture

Smart Sensors
      |
      V
    ESP32
      |
      V
     n8n
      |
 ------------------
 |       |        |
 V       V        V
AI   Google   ThingSpeak
Agent Sheets Dashboard
 |
 V
Telegram Alerts

3. Components List

Component Quantity
ESP32 Dev Board1
ACS712 Current Sensor1
ZMPT101B Voltage Sensor1
Relay Module1
OLED Display1
WiFi Router1
Power Supply1

4. Circuit Connections

Module ESP32 Pin
ACS712 OUTGPIO34
ZMPT101B OUTGPIO35
OLED SDAGPIO21
OLED SCLGPIO22
Relay INGPIO26

5. Flowchart

START
 |
ESP32 Initialization
 |
Connect WiFi
 |
Read Sensors
 |
Calculate Power
 |
Send Data to n8n
 |
AI Analysis
 |
Load High?
 /     \
Yes     No
 |       |
Alert  Continue
 |
Voice Alert
 |
Relay Control
 |
Repeat

6. Power Calculation

Power = Voltage × Current

7. ESP32 Arduino Source Code

#include <WiFi.h>
#include <HTTPClient.h>

const char* ssid="YOUR_WIFI";
const char* password="YOUR_PASSWORD";

String webhookURL=
"https://your-n8n-domain/webhook/energy";

void setup()
{
 Serial.begin(115200);

 WiFi.begin(ssid,password);

 while(WiFi.status()!=WL_CONNECTED)
 {
   delay(500);
 }
}

void loop()
{
 float voltage=220;
 float current=5;

 float power=voltage*current;

 HTTPClient http;

 http.begin(webhookURL);

 http.addHeader(
 "Content-Type",
 "application/json"
 );

 String payload=
 "{";

 payload += "\"voltage\":220,";
 payload += "\"current\":5,";
 payload += "\"power\":1100";

 payload += "}";

 http.POST(payload);

 http.end();

 delay(15000);
}

8. n8n Workflow

Workflow Sequence:

  1. Webhook Node
  2. Function Node
  3. AI Agent Node
  4. IF Condition
  5. Telegram Node
  6. Google Sheets Node
  7. ThingSpeak Update Node

9. Telegram Bot Setup

  1. Open Telegram
  2. Search BotFather
  3. Create new bot using /newbot
  4. Copy Bot Token
  5. Get Chat ID
  6. Configure in n8n

10. Google Sheets Integration

Timestamp Voltage Current Power Prediction Status
2026-06-12 230 4.2 966 1050 Normal

11. ThingSpeak Dashboard Fields

  • Field1 = Voltage
  • Field2 = Current
  • Field3 = Power
  • Field4 = Prediction

12. AI Prediction Logic

Future Power =
(P1+P2+P3+P4+P5)/5

The AI Agent predicts future energy consumption using historical readings, moving averages, machine learning, or LSTM forecasting models.

13. Voice Notification Logic

ESP32 Data
     |
     V
n8n Workflow
     |
Text-To-Speech
     |
MP3 Generation
     |
Telegram Voice Message

14. Agentic AI Decision Rules

Condition Action
Power > 1000W Warning Alert
Power > 1500W Relay Shutdown
Peak Load Expected Optimization Suggestion

15. Future Enhancements

  • LSTM Forecasting
  • MQTT Integration
  • Grafana Dashboard
  • Solar Monitoring
  • Battery Management
  • Reinforcement Learning
  • Edge AI Processing

16. Deployment Architecture

ESP32
 |
MQTT Broker
 |
n8n Automation
 |
AI Agent
 |
-----------------
|       |       |
V       V       V
Sheets  Cloud  Telegram
Project Folder Structure SmartGridProject/ │ ├── index.php ├── css/ │ └── style.css │ ├── images/ │ ├── architecture.png │ ├── circuit.png │ └── flowchart.png │ ├── docs/ │ ├── ESP32_Code.ino │ ├── n8n_Workflow.json │ └── README.pdf │ └── assets/ For a final-year project, a better approach is to create a complete PHP web application with Login Page, Live Dashboard, ThingSpeak API Integration, Google Sheets Logging, Telegram Alert Management, AI Prediction Charts, MySQL Database, and Admin Panel rather than a single static PHP page

AI-Powered Remote Patient Health Monitoring & Predictive Disease Alert System Using ESP8266 and Arduino

AI-Powered Remote Patient Health Monitoring & Predictive Disease Alert System Using ESP32/ESP8266 + Sensors + n8n Automation + AI Agent + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard
<?php echo $title; ?>

AI-Powered Remote Patient Health Monitoring & Predictive Disease Alert System

ESP32 + IoT + AI Agent + n8n + Telegram Voice Alerts + Google Sheets + ThingSpeak

1. Project Overview

This project continuously monitors patient health parameters using IoT sensors connected to an ESP32 board. Data is uploaded to ThingSpeak Cloud, stored in Google Sheets, analyzed using AI, and critical alerts are sent through Telegram including voice notifications.

2. Features

  • Real-Time Health Monitoring
  • Heart Rate Monitoring
  • Blood Oxygen (SpO2) Monitoring
  • Body Temperature Monitoring
  • Cloud Dashboard
  • Google Sheets Data Logging
  • AI Disease Prediction
  • Telegram Notification Alerts
  • Voice Alerts
  • Remote Doctor Monitoring

3. Components List

Component Quantity
ESP32 Dev Board 1
MAX30102 Sensor 1
DHT11 Sensor 1
LM35 Sensor 1
OLED Display 1
Jumper Wires As Required
Breadboard 1

4. Circuit Connections

MAX30102 → ESP32

VIN  → 3.3V
GND  → GND
SDA  → GPIO21
SCL  → GPIO22

DHT11 → ESP32

VCC → 3.3V
GND → GND
DATA → GPIO4

LM35 → ESP32

VCC → 3.3V
GND → GND
OUT → GPIO34

5. System Architecture

Patient
   |
Sensors
   |
ESP32
   |
ThingSpeak Cloud
   |
+------------------------+
|                        |
Google Sheets         AI Agent
|                        |
Database            Risk Prediction
|                        |
+----------+-------------+
           |
     Telegram Alerts
           |
     Voice Notification

6. AI Prediction Logic

IF Temperature > 38°C
THEN Fever Risk

IF Heart Rate > 100
THEN Tachycardia

IF Heart Rate < 60
THEN Bradycardia

IF SpO2 < 92
THEN Respiratory Risk

IF SpO2 < 90 AND HR > 120
THEN Critical Alert

7. ESP32 Source Code

#include <WiFi.h>
#include <HTTPClient.h>

const char* ssid="YOUR_WIFI";
const char* password="YOUR_PASSWORD";

String apiKey="YOUR_THINGSPEAK_API_KEY";

void setup()
{
  Serial.begin(115200);

  WiFi.begin(ssid,password);

  while(WiFi.status()!=WL_CONNECTED)
  {
      delay(500);
      Serial.print(".");
  }
}

void loop()
{
   float hr=90;
   float spo2=98;
   float temp=36.8;

   HTTPClient http;

   String url=
   "http://api.thingspeak.com/update?api_key="+apiKey+
   "&field1="+String(hr)+
   "&field2="+String(spo2)+
   "&field3="+String(temp);

   http.begin(url);
   http.GET();
   http.end();

   delay(15000);
}

8. ThingSpeak Setup

  1. Create ThingSpeak Account
  2. Create New Channel
  3. Add Fields:
    • Heart Rate
    • SpO2
    • Temperature
    • Humidity
  4. Copy Write API Key
  5. Use API Key in ESP32 Code

9. Google Sheets Integration

function doPost(e)
{
 var sheet =
 SpreadsheetApp.getActiveSpreadsheet()
 .getSheetByName("Sheet1");

 var data =
 JSON.parse(e.postData.contents);

 sheet.appendRow([
   new Date(),
   data.hr,
   data.spo2,
   data.temp,
   data.status
 ]);

 return ContentService
 .createTextOutput("Success");
}

10. Telegram Bot Setup

  1. Open Telegram
  2. Search @BotFather
  3. Create New Bot
  4. Get Bot Token
  5. Get Chat ID
  6. Use Token in n8n Workflow

11. n8n Workflow

ThingSpeak Trigger
       |
       ▼
Webhook
       |
       ▼
AI Analysis
       |
       ▼
IF Condition
       |
   +---+---+
   |       |
Normal  Critical
   |       |
Sheets Telegram
 Update Alerts

12. Voice Notification Automation

ESP32 Data
     |
ThingSpeak
     |
n8n Workflow
     |
OpenAI / Gemini
     |
Generate Alert Text
     |
Google TTS
     |
MP3 Voice File
     |
Telegram Voice Message

13. Power Consumption Formula

Power = Voltage × Current

Battery Life =
Battery Capacity(mAh)
---------------------
Average Current(mA)

14. Future Enhancements

  • ECG Sensor Integration
  • Blood Pressure Monitoring
  • LSTM Disease Prediction
  • Doctor Mobile Application
  • AWS IoT Integration
  • Firebase Database
  • GPS Emergency Tracking
  • Hospital Dashboard

15. Deployment Guide

  1. Build Hardware
  2. Upload ESP32 Code
  3. Configure ThingSpeak
  4. Connect Google Sheets
  5. Configure n8n Workflow
  6. Create Telegram Bot
  7. Connect AI Agent
  8. Test Alerts
  9. Deploy System

AI-Based Smart Battery Management System for EV Applications

AI-Based Smart Battery Management System (BMS) for EV Applications Using ESP32 + Agentic AI + IoT + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard
AI-Based Smart Battery Management System (BMS) for EV Applications Using ESP32 + Agentic AI + IoT + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard 1. Project Overview Project Title AI-Based Smart Battery Management System for Electric Vehicle Applications Using ESP32, Agentic AI, n8n Automation, Telegram Voice Notifications, Google Sheets, and ThingSpeak Cloud Analytics Objective Develop a smart battery monitoring and predictive maintenance system for EV batteries that: Monitors battery voltage, current, temperature, and State of Charge (SOC) Uploads data to cloud platforms Uses AI to predict battery health and power consumption Sends real-time Telegram notifications Generates voice alerts automatically Stores historical data in Google Sheets Displays live dashboard on ThingSpeak Uses n8n as an intelligent automation engine Supports future EV fleet management 2. System Architecture Battery Pack │ ▼ Voltage Sensor Current Sensor Temperature Sensor │ ▼ ESP32 │ ├────────► ThingSpeak Dashboard │ ├────────► n8n Webhook │ │ ▼ │ AI Prediction Agent │ ▼ │ Decision Engine │ ├────────► Google Sheets │ ▼ Telegram Bot │ ▼ Voice Alert Message 3. Features Real-Time Monitoring Battery Voltage Battery Current Battery Temperature State of Charge (SOC) AI Functions Battery Health Prediction Remaining Runtime Estimation Power Consumption Forecasting Fault Detection IoT Features Cloud Dashboard Data Logging Remote Monitoring Automation Features Telegram Alerts Voice Notifications Google Sheets Logging AI Recommendations 4. Hardware Components Component Quantity ESP32 Dev Board 1 INA219 Current Sensor 1 Voltage Divider Circuit 1 DS18B20 Temperature Sensor 1 EV Battery Pack (12V/24V/48V) 1 OLED Display (Optional) 1 Jumper Wires Several Breadboard/PCB 1 WiFi Router 1 5. Sensor Selection INA219 Current Sensor Measures: Voltage Current Power Communication: I2C Protocol DS18B20 Temperature Sensor Measures: Battery Temperature Range: -55°C to +125°C Voltage Divider Converts: 48V Battery ↓ 3.3V ESP32 ADC Formula: V out ​ =V in ​ × R 1 ​ +R 2 ​ R 2 ​ ​ Example: R1 = 100kΩ R2 = 10kΩ 6. Circuit Schematic Battery + │ ├── Voltage Divider ── GPIO34 Battery + │ └── INA219 Sensor INA219 SDA → GPIO21 SCL → GPIO22 DS18B20 DATA → GPIO4 VCC → 3.3V GND → GND ESP32 Connected to WiFi 7. Pin Configuration Device ESP32 Pin INA219 SDA GPIO21 INA219 SCL GPIO22 DS18B20 Data GPIO4 Voltage Sensor GPIO34 8. Working Principle Step 1 ESP32 reads: Voltage Current Temperature Step 2 Calculates: Battery Power State of Charge Power Formula: P=V×I Step 3 Uploads data to: ThingSpeak n8n Webhook Step 4 n8n receives data Example: { "voltage": 48.5, "current": 12.4, "temperature": 35, "soc": 82 } Step 5 AI Agent analyzes battery condition Possible outputs: Battery Healthy Battery Overheating High Power Consumption Low SOC Warning Step 6 Telegram Voice Alert Sent Example: Warning! Battery Temperature is 48°C. Please stop charging immediately. 9. State of Charge Calculation Simple SOC estimation: SOC= V max ​ −V min ​ V battery ​ −V min ​ ​ ×100 Example: Battery Voltage = 48V SOC = 80% 10. AI Power Consumption Prediction Inputs Voltage Current Temperature Historical Usage AI Logic Dataset: Voltage Current Temperature SOC Runtime Model: Linear Regression Random Forest LSTM Prediction: Expected Runtime Remaining Power Consumption Trend Battery Health Score Pseudo Logic if temperature > 45: health_score -= 20 if current > threshold: health_score -= 10 if soc < 20: alert = True 11. ESP32 Source Code #include #include #include #include const char* ssid="YOUR_WIFI"; const char* password="YOUR_PASSWORD"; String apiKey="THINGSPEAK_API_KEY"; Adafruit_INA219 ina219; float voltage; float current; float power; void setup() { Serial.begin(115200); WiFi.begin(ssid,password); while(WiFi.status()!=WL_CONNECTED) { delay(500); } ina219.begin(); } void loop() { voltage=ina219.getBusVoltage_V(); current=ina219.getCurrent_mA()/1000; power=voltage*current; sendThingSpeak(); sendn8n(); delay(15000); } ThingSpeak Upload Function void sendThingSpeak() { HTTPClient http; String url= "http://api.thingspeak.com/update?api_key="+ apiKey+ "&field1="+String(voltage)+ "&field2="+String(current)+ "&field3="+String(power); http.begin(url); http.GET(); http.end(); } n8n Webhook Function void sendn8n() { HTTPClient http; http.begin( "https://your-n8n-server/webhook/battery"); http.addHeader( "Content-Type", "application/json"); String data= "{\"voltage\":"+String(voltage)+ ",\"current\":"+String(current)+ "}"; http.POST(data); http.end(); } 12. n8n Workflow Design Workflow Nodes Webhook ↓ Set Data ↓ AI Analysis ↓ IF Condition ↓ Telegram Alert ↓ Google Sheets Detailed Flow Webhook Node Receives sensor data. Example: { "voltage":48, "current":10, "temperature":36, "soc":75 } AI Agent Node Prompt: Analyze battery data. Voltage: {{$json.voltage}} Current: {{$json.current}} Temperature: {{$json.temperature}} SOC: {{$json.soc}} Give: 1. Health Score 2. Remaining Runtime 3. Recommendation IF Node Condition: Temperature > 45°C OR SOC < 20% Telegram Node Message: ⚠️ Battery Alert Voltage: 48V SOC: 15% Action Required 13. n8n Workflow JSON (Simplified) { "nodes": [ { "name": "Webhook" }, { "name": "AI Agent" }, { "name": "Telegram" }, { "name": "Google Sheets" } ] } 14. 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 Add token to n8n Telegram node. 15. Voice Notification Automation Method Use Text-To-Speech API. Workflow: AI Alert ↓ Google TTS ↓ Audio File ↓ Telegram Send Voice Voice Example: Attention! Battery temperature exceeds safe limit. Please inspect immediately. 16. Google Sheets Integration Create Sheet: Battery Monitoring Log Columns: Timestamp Voltage Current Temp SOC Health n8n Node Google Sheets Node Action: Append Row Stored Data Example 2026-06-11 48.4 10.3 35 80 Healthy 17. ThingSpeak Dashboard Setup Step 1 Create account on ThingSpeak Step 2 Create New Channel Fields: Field1 Voltage Field2 Current Field3 Temperature Field4 SOC Field5 Health Score Step 3 Enable Public Dashboard Step 4 Add Widgets Gauge Line Chart Battery Indicator Temperature Trend 18. Agentic AI Decision Engine AI evaluates: Battery Health Charging Pattern Discharge Pattern Thermal Condition Decision Rules: if temp > 45: send_alert() if soc < 20: send_alert() if health < 70: maintenance_required() 19. Future Enhancements Advanced AI LSTM Battery Degradation Prediction Predictive Maintenance Remaining Useful Life (RUL) EV Fleet Management Monitor: 100+ Vehicles through one dashboard. Mobile App Features: Live Battery Status Notifications Maintenance Alerts Route-Based Energy Prediction Digital Twin Create virtual battery model for simulation. 20. Project Execution Guide (Step-by-Step) Phase 1: Hardware Setup Assemble ESP32. Connect INA219. Connect DS18B20. Connect voltage divider. Verify sensor readings. Phase 2: Cloud Setup Create ThingSpeak channel. Obtain Write API Key. Test data upload. Phase 3: n8n Setup Install n8n. Create Webhook. Create AI Agent node. Configure Telegram node. Configure Google Sheets node. Phase 4: AI Integration Collect battery data. Train prediction model. Deploy model API. Connect API to n8n. Phase 5: Testing Simulate low SOC. Simulate overheating. Verify alerts. Verify voice notifications. Verify cloud logging. Phase 6: Deployment Install in EV battery enclosure. Enable Wi-Fi/4G connectivity. Secure API endpoints. Monitor dashboard. Perform periodic calibration. Expected Project Outcomes Real-time EV battery monitoring AI-based battery health prediction Automatic Telegram voice alerts Cloud-based analytics dashboard Historical logging in Google Sheets Predictive maintenance recommendations Industry-ready Agentic IoT architecture suitable for smart EVs, e-bikes, solar battery banks, and fleet management systems.