Thursday, 20 August 2026

AI-Powered Smart Power Grid Monitoring & Safety Automation Using ESP32, IoT, n8n, Web Dashboard and Telegram Voice Alerts

AI-Powered Smart Power Grid Monitoring & Safety Automation Using ESP32

1. Project Title

AI-Powered Smart Power Grid Monitoring and Safety Automation Using ESP32, IoT, n8n, AI Agent, Web Dashboard and Telegram Voice Alerts

Short title

Agentic AI-Based Smart Power Grid Monitoring and Safety System


2. Abstract

The proposed system is an intelligent IoT-based electrical power monitoring and safety platform designed to continuously monitor electrical parameters such as voltage, current, power, energy consumption, frequency, temperature, and abnormal operating conditions.

An ESP32 acts as the edge controller. Sensors connected to the ESP32 acquire electrical and environmental measurements. The ESP32 processes the measurements locally and transmits the data to an IoT/cloud layer.

The system uses n8n as the automation and orchestration platform. n8n receives sensor data, evaluates predefined safety conditions, stores measurements in Google Sheets, publishes data to ThingSpeak, updates a web dashboard, and communicates with an AI agent.

When an abnormal condition such as over-voltage, under-voltage, over-current, excessive temperature, overload, or abnormal power consumption is detected, the automation system generates an alert. The AI agent can analyze the event and determine the appropriate response according to predefined safety rules.

The system can then send a Telegram notification and voice alert to the user. In severe situations, the ESP32 can activate a local protection mechanism such as a relay/contactor to disconnect a properly isolated, low-voltage-controlled load.

The project therefore combines:

Edge IoT + ESP32 + Electrical Monitoring + AI Agent + n8n Automation + Cloud Storage + Web Dashboard + Telegram Voice Alerts


3. Main Objectives

The major objectives are:

  1. Monitor electrical parameters in real time.
  2. Detect electrical abnormalities automatically.
  3. Process critical safety conditions at the ESP32 edge.
  4. Send sensor data to the cloud.
  5. Automate data processing using n8n.
  6. Use an AI agent for intelligent event analysis.
  7. Display measurements on a web dashboard.
  8. Store historical measurements in Google Sheets.
  9. Visualize IoT data using ThingSpeak.
  10. Send Telegram notifications.
  11. Generate Telegram voice alerts for critical events.
  12. Maintain an event/safety log.
  13. Automatically activate a protection output when a predefined dangerous condition occurs.
  14. Provide remote monitoring through the Internet.

4. Overall System Architecture

The complete system can be divided into six layers.

┌───────────────────────────────────────────────────────────┐
│ ELECTRICAL SYSTEM │
│ │
│ Voltage ──┐ │
│ Current ──┤ │
│ Power ────┤──> Sensors / Metering Circuit │
│ Energy ───┤ │
│ Temp ─────┘ │
└─────────────────────────┬─────────────────────────────────┘
┌───────────────────────────────────────────────────────────┐
│ EDGE LAYER │
│ │
│ ESP32 │
│ │
│ Sensor Reading │
│ Local Filtering │
│ Threshold Checking │
│ Emergency Logic │
│ Wi-Fi Communication │
│ Relay/Contactor Control* │
└─────────────────────────┬─────────────────────────────────┘
│ Wi-Fi / HTTPS / MQTT
┌───────────────────────────────────────────────────────────┐
│ IoT / AUTOMATION LAYER │
│ │
│ n8n │
│ │
│ Receive Data │
│ ↓ │
│ Validate Data │
│ ↓ │
│ Safety Rules │
│ ↓ │
│ AI Agent │
│ ↓ │
│ Decision / Classification │
└──────────────┬──────────┬──────────┬──────────────────────┘
│ │ │
▼ ▼ ▼
Google Sheets ThingSpeak Database
│ │
└────┬─────┘
Web Dashboard
User / Engineer
Telegram Bot
┌────────┴────────┐
▼ ▼
Text Alert Voice Alert

* For an actual mains/high-voltage installation, the protection hardware must be properly rated, isolated and installed by a qualified person. The ESP32 should not directly switch mains voltage.


5. Hardware Requirements

5.1 Main Controller

ESP32 Development Board

Recommended:

  • ESP32 DevKit V1
  • ESP32-WROOM-32
  • ESP32-S3 if additional processing/peripherals are desired

The ESP32 provides:

  • Wi-Fi
  • GPIO
  • ADC
  • UART
  • I²C
  • SPI
  • sufficient processing capability
  • low-cost edge computing

6. Sensors

The exact sensors depend on whether this is a laboratory low-voltage prototype or a real electrical installation.

Voltage measurement

Possible approach:

AC voltage sensor/module → isolated measurement → ESP32 ADC

For a prototype, an appropriately isolated voltage-sensing module can be used.

Current measurement

Possible options:

  • Current transformer
  • Hall-effect current sensor
  • INA219/INA226 for suitable DC applications

For AC mains measurement, a properly rated current transformer or isolated current transducer is preferable.

Temperature

Possible:

  • DS18B20
  • DHT22 for ambient monitoring
  • thermistor
  • industrial temperature sensor

For electrical-panel temperature, an appropriately mounted temperature sensor is preferable.

Energy measurement

Energy can be calculated approximately from:

Energy = Power × Time

For more accurate electrical metering, use a dedicated energy-metering IC/module or certified meter.


7. Protection Components

A prototype can include:

ESP32 GPIO
Driver Circuit
Relay / Contactor Control

Important:

Do not connect a relay module directly to an uncontrolled mains circuit merely because the relay is labeled "10 A" or "250 V".

For an academic prototype, demonstrate the switching function using a safe low-voltage load such as a DC lamp or DC motor.

For real distribution equipment, use appropriately rated:

  • contactor
  • fuse/MCB
  • circuit breaker
  • overload protection
  • surge protection
  • isolation
  • emergency shutdown

and have the electrical installation professionally designed.


8. Suggested Hardware Block Diagram

┌──────────────────┐
│ Electrical Load │
└────────┬─────────┘
┌───────┴────────┐
│ │
▼ ▼
Voltage Sensor Current Sensor
│ │
└───────┬────────┘
┌────────┐
Temperature ───►│ ESP32 │
Sensor │ │
└───┬────┘
┌───────┼───────────┐
│ │ │
▼ ▼ ▼
Relay Wi-Fi Local
Control │ Alarm
n8n

9. ESP32 Responsibilities

The ESP32 is the edge intelligence layer.

It should:

  1. Read sensors.
  2. Filter noisy readings.
  3. Calculate electrical parameters.
  4. Check safety thresholds.
  5. Identify immediate dangerous conditions.
  6. Send telemetry to the server.
  7. Receive commands.
  8. Control a safe protection output.
  9. Continue basic protection even if the Internet is unavailable.

This last point is extremely important.

Do not make the Internet your only safety mechanism.

For example:

Sensor
ESP32
├── Safe → Normal operation
└── Dangerous
├── Local protection
├── Local alarm
└── Send cloud event

The AI agent should assist monitoring and decision support, while deterministic safety rules remain responsible for immediate protection.


10. Example Safety Parameters

For an educational prototype, you can define configurable thresholds such as:

Parameter Example Normal Range Action
Voltage Configurable Detect under/over-voltage
Current Configurable Detect over-current
Power Configurable Detect overload
Temperature Configurable Detect overheating
Frequency Configurable Detect abnormal frequency
Energy Configurable Monitor consumption
Sensor status Valid Detect sensor failure

Don't copy these values blindly into a real power system. Thresholds should be based on the actual equipment and applicable electrical standards.


11. Operating Modes

The system can have four modes.

MODE 1 — NORMAL

Voltage ✓
Current ✓
Temperature ✓
Power ✓
Internet ✓
NORMAL STATE

Dashboard:

SYSTEM STATUS: 🟢 NORMAL

MODE 2 — WARNING

Example:

Current slightly above normal

System:

ESP32
n8n
AI Analysis
WARNING
Telegram notification

MODE 3 — CRITICAL

Example:

Over-current detected

Flow:

Sensor
ESP32
Local Safety Rule
Protection Output
n8n
AI Agent
Telegram Voice Alert

MODE 4 — COMMUNICATION FAILURE

If Internet connectivity disappears:

ESP32
├── Local monitoring continues
├── Local safety protection continues
└── Data buffered locally

When connectivity returns:

ESP32
Upload buffered measurements

12. IoT Data Format

A useful JSON telemetry structure is:

{
"device_id": "ESP32_GRID_01",
"timestamp": "2026-08-20T23:00:00",
"voltage": 230.4,
"current": 4.82,
"power": 1089.5,
"energy": 12.73,
"temperature": 36.4,
"frequency": 50.02,
"status": "NORMAL",
"alarm": false
}

An alarm message could be:

{
"device_id": "ESP32_GRID_01",
"event": "OVER_CURRENT",
"voltage": 228.6,
"current": 12.4,
"power": 2834.1,
"temperature": 48.2,
"severity": "CRITICAL",
"timestamp": "2026-08-20T23:02:12"
}

13. n8n Automation Architecture

The n8n workflow can be designed as:

ESP32
┌──────────────┐
│ Webhook/MQTT │
└──────┬───────┘
┌───────────────┐
│ Validate JSON │
└──────┬────────┘
┌───────────────┐
│ Normalize Data│
└──────┬────────┘
┌───────────────┐
│ Safety Rules │
└──────┬────────┘
┌──────┴──────────┐
│ │
▼ ▼
NORMAL ABNORMAL
│ │
│ ▼
│ AI Agent
│ │
│ ┌────────┴─────────┐
│ │ │
│ ▼ ▼
│ WARNING CRITICAL
│ │ │
└────────┼──────────────────┘
┌────────────────┐
│ Google Sheets │
└────────────────┘
ThingSpeak
Web Dashboard
Telegram
┌──────┴──────┐
▼ ▼
Text Voice

14. n8n Node-by-Node Workflow

Node 1 — Webhook

ESP32 sends:

POST /webhook/power-monitor

Body:

{
"device_id": "ESP32_GRID_01",
"voltage": 230.4,
"current": 4.82,
"power": 1089.5,
"temperature": 36.4
}

Node 2 — JSON Validation

Check:

device_id exists
voltage exists
current exists
timestamp exists

If invalid:

Reject packet

15. Node 3 — Function/Code Processing

n8n can calculate:

Power
Severity
Alarm state
Event type

Example logic:

const voltage = Number($json.voltage);
const current = Number($json.current);
const temperature = Number($json.temperature);
let severity = "NORMAL";
let event = "NORMAL";
if (temperature > 60) {
severity = "CRITICAL";
event = "OVER_TEMPERATURE";
} else if (current > 10) {
severity = "CRITICAL";
event = "OVER_CURRENT";
} else if (voltage > 250) {
severity = "WARNING";
event = "OVER_VOLTAGE";
}
return [{
json: {
...$json,
severity,
event
}
}];

These are example software thresholds, not real installation settings.


16. Node 4 — IF/Switch Node

severity
├── NORMAL
├── WARNING
└── CRITICAL

17. AI Agent

The AI agent receives structured information such as:

Device: ESP32_GRID_01
Voltage: 228.6 V
Current: 12.4 A
Power: 2834 W
Temperature: 48.2 °C
Event: OVER_CURRENT
Severity: CRITICAL

The AI agent can produce:

Classification:
CRITICAL
Reason:
Current is significantly above the configured operating threshold.
Recommended action:
Keep the protection state active and notify the operator.
Operator message:
"Critical over-current condition detected on Grid Device 01."

18. Important AI Safety Design

The AI should not be the sole authority for emergency electrical protection.

Use:

Deterministic Safety Logic
+
AI Analysis

instead of:

AI
Directly control mains

A safer architecture is:

Sensor
ESP32
┌─────────┴──────────┐
│ │
▼ ▼
Safety Rule Engine Cloud
│ │
▼ ▼
Protection n8n + AI
Notification

19. Telegram Alert System

The Telegram bot can send:

Normal notification

🟢 POWER GRID STATUS
Device: ESP32_GRID_01
Voltage: 230.4 V
Current: 4.82 A
Power: 1089 W
Temperature: 36.4 °C
Status: NORMAL

Critical notification

🚨 CRITICAL POWER ALERT
Device: ESP32_GRID_01
Event: OVER CURRENT
Current: 12.4 A
Voltage: 228.6 V
Power: 2834 W
Temperature: 48.2 °C
Severity: CRITICAL
Protection status: ACTIVE

20. Telegram Voice Alert

The voice-alert pipeline can be:

ESP32
n8n
AI Agent
Generate Alert Text
Text-to-Speech
Audio File
Telegram Bot
User's Phone

Example voice message:

"Critical power alert. Over-current has been detected on Grid Device 01. Please inspect the electrical system."

The voice message makes the project considerably more useful than a simple text notification.


21. Google Sheets Integration

Google Sheets can act as a simple historical log.

Recommended columns:

Timestamp Device Voltage Current Power Energy Temperature Event Severity Action
23:00 GRID01 230.4 4.82 1089 12.73 36.4 NORMAL NORMAL None
23:02 GRID01 228.6 12.4 2834 12.78 48.2 OVER_CURRENT CRITICAL Protection

This allows:

  • historical analysis
  • report generation
  • fault investigation
  • energy analysis
  • academic demonstration

22. ThingSpeak Integration

ThingSpeak can provide IoT visualization.

Example fields:

Field 1 → Voltage
Field 2 → Current
Field 3 → Power
Field 4 → Energy
Field 5 → Temperature
Field 6 → Frequency
Field 7 → Alarm

Dashboard:

┌─────────────────────────────────────┐
│ POWER GRID MONITOR │
├─────────────────────────────────────┤
│ Voltage 230.4 V │
│ Current 4.82 A │
│ Power 1089 W │
│ Energy 12.73 kWh │
│ Temperature 36.4 °C │
│ Frequency 50.02 Hz │
├─────────────────────────────────────┤
│ Status: 🟢 NORMAL │
└─────────────────────────────────────┘

23. Web Dashboard

A custom web dashboard can provide a professional user interface.

Dashboard sections

Header

AI SMART POWER GRID
ESP32 MONITORING SYSTEM

Device status

ESP32-GRID-01
🟢 ONLINE

Live parameters

┌────────────┬────────────┬────────────┐
│ VOLTAGE │ CURRENT │ POWER │
│ 230.4 V │ 4.82 A │ 1089 W │
└────────────┴────────────┴────────────┘
┌────────────┬────────────┬────────────┐
│ ENERGY │ TEMP │ FREQUENCY │
│ 12.73 kWh │ 36.4 °C │ 50.02 Hz │
└────────────┴────────────┴────────────┘

24. Dashboard Status Indicator

🟢 NORMAL
🟡 WARNING
🔴 CRITICAL
⚫ OFFLINE

25. Dashboard Event Log

TIME DEVICE EVENT STATUS
------------------------------------------------
23:00:01 GRID01 NORMAL 🟢
23:01:15 GRID01 HIGH CURRENT 🟡
23:02:12 GRID01 OVER CURRENT 🔴
23:02:13 GRID01 PROTECTION ACTIVE 🔴
23:05:42 GRID01 SYSTEM NORMAL 🟢

26. Complete Data Flow

┌──────────────┐
│ Electrical │
│ Parameters │
└──────┬───────┘
┌──────────────┐
│ Sensors │
└──────┬───────┘
┌──────────┐
│ ESP32 │
└────┬─────┘
Local safety check
┌──────┴───────┐
│ │
Normal Fault
│ │
└──────┬───────┘
Wi-Fi
n8n
┌───────────┼────────────┐
▼ ▼ ▼
Database AI Agent Google Sheets
│ │
│ ▼
│ Decision
│ │
└─────┬─────┘
Web Dashboard
Telegram
/ \
Text Voice

27. ESP32 Software Architecture

The ESP32 firmware should be divided into modules.

main.cpp
├── sensor_manager
├── electrical_calculation
├── safety_manager
├── wifi_manager
├── cloud_manager
├── relay_manager
└── watchdog_manager

28. Example ESP32 Arduino Code

Below is a prototype software framework. The sensor-reading functions must be replaced with the actual calibrated, isolated measurement hardware you use.

#include <WiFi.h>
#include <HTTPClient.h>
#include <ArduinoJson.h>
const char* WIFI_SSID = "YOUR_WIFI";
const char* WIFI_PASSWORD = "YOUR_PASSWORD";
const char* SERVER_URL =
"https://YOUR-N8N-SERVER/webhook/power-monitor";
const int RELAY_PIN = 26;
const int LED_PIN = 2;
// Example software thresholds only.
// Do NOT use these values directly for a real electrical installation.
const float MAX_CURRENT = 10.0;
const float MAX_TEMPERATURE = 60.0;
const float MAX_VOLTAGE = 250.0;
float voltage = 0.0;
float current = 0.0;
float power = 0.0;
float temperature = 0.0;
String severity = "NORMAL";
String eventName = "NORMAL";
void connectWiFi() {
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("Connecting to WiFi");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println();
Serial.println("WiFi connected");
}
void readSensors() {
/*
Replace these examples with readings
from your actual sensor circuitry.
*/
voltage = 230.0;
current = 4.5;
temperature = 35.0;
power = voltage * current;
}
void safetyCheck() {
severity = "NORMAL";
eventName = "NORMAL";
bool critical = false;
if (current > MAX_CURRENT) {
severity = "CRITICAL";
eventName = "OVER_CURRENT";
critical = true;
}
if (temperature > MAX_TEMPERATURE) {

29. Improved Production Architecture

For the final version, don't put everything inside loop().

Use:

FreeRTOS Tasks
├── Sensor Task
├── Safety Task
├── Communication Task
├── Data Logging Task
└── Watchdog Task

This makes the firmware much more robust.


30. AI Agent Decision Architecture

The AI agent can receive a structured event:

{
"device_id": "ESP32_GRID_01",
"event": "OVER_CURRENT",
"current": 12.4,
"voltage": 228.6,
"power": 2834,
"temperature": 48.2,
"severity": "CRITICAL"
}

The AI should return structured information:

{
"classification": "CRITICAL",
"summary": "Over-current condition detected.",
"recommended_action": "Maintain protection state and alert operator.",
"notify_user": true,
"voice_alert": true
}

This is preferable to allowing arbitrary AI-generated commands to control hardware.


31. Agentic IoT Concept

The project becomes agentic when the system can perform a sequence of tasks rather than simply forwarding sensor data.

For example:

Observe
Analyze
Classify
Decide
Act
Notify
Record
Verify

Example:

ESP32 observes:
Current = 12.4 A
n8n receives event
Safety engine:
CRITICAL
AI Agent:
Over-current event
System:
Protection active
Telegram:
Voice alert
Google Sheets:
Event recorded
Dashboard:
RED ALERT
System waits for recovery
Normal condition detected
Telegram:
"System returned to normal."

32. Fault-Recovery Workflow

FAULT
Protection Activated
Telegram Alert
Monitor Parameters
Is condition safe?
┌┴──────────┐
│ │
NO YES
│ │
▼ ▼
Continue Recovery
Protection Logic
│ │
│ ▼
└──────► Operator Notification

For a real electrical system, automatic re-energization should not be implemented casually. Recovery/reclosing must follow the characteristics of the equipment and the applicable protection design.


33. Web Dashboard Software Stack

A suitable stack is:

Frontend:
HTML
CSS
JavaScript
Backend:
Node.js / Python / n8n
IoT:
ESP32
Cloud:
ThingSpeak
Automation:
n8n
Storage:
Google Sheets / Database
AI:
LLM-based AI Agent
Notification:
Telegram Bot

34. Example Dashboard HTML

A simple prototype can start with:

<!DOCTYPE html>
<html>
<head>
<title>AI Smart Power Grid</title>
<style>
body {
font-family: Arial, sans-serif;
background: #101820;
color: white;
margin: 0;
padding: 30px;
}
h1 {
text-align: center;
}
.dashboard {
display: grid;
grid-template-columns:
repeat(auto-fit, minmax(200px, 1fr));
gap: 20px;
}
.card {
background: #1d2a35;
padding: 25px;
border-radius: 15px;
text-align: center;
}
.value {
font-size: 32px;
color: #00d9ff;
}
.normal {
color: #00ff88;
}
.warning {
color: #ffd000;
}
.critical {
color: #ff4040;
}
</style>
</head>
<body>
<h1>AI SMART POWER GRID</h1>
<div class="dashboard">
<div class="card">
<h3>Voltage</h3>
<div class="value" id="voltage">-- V</div>
</div>
<div class="card">
<h3>Current</h3>
<div class="value" id="current">-- A</div>
</div>
<div class="card">
<h3>Power</h3>

35. Security Architecture

This project should include cybersecurity because the ESP32 is connected to the Internet.

Recommended:

ESP32
│ HTTPS
n8n
├── Authentication
├── Validation
├── Rate limiting
└── Logging

Use:

  • HTTPS
  • authentication tokens/API keys
  • secret storage
  • strong Wi-Fi credentials
  • n8n credentials management
  • input validation
  • device identification
  • TLS where supported
  • no hard-coded production secrets in public source code

36. Watchdog System

The ESP32 should use a watchdog strategy.

ESP32
├── Sensor task alive?
├── Communication task alive?
├── Safety task alive?
└── Watchdog
└── Fault → controlled restart

The local safety state should fail in a predictable manner.


37. Offline Data Buffer

If Wi-Fi fails:

Sensor
ESP32
Local buffer
Wi-Fi unavailable

After reconnection:

Wi-Fi restored
Upload buffered records
Cloud database

For larger systems, use non-volatile storage carefully to avoid excessive flash wear.


38. Complete n8n Workflow

A practical workflow could look like:

[Webhook]
[Validate JSON]
[Normalize Data]
[Safety Rule]
├────────────── NORMAL ───────────────┐
│ │
▼ ▼
[AI Agent] [Google Sheets]
│ │
▼ │
[Severity] │
│ │
┌──┴───────────────┐ │
│ │ │
▼ ▼ │
WARNING CRITICAL │
│ │ │
▼ ▼ │
Telegram Protection │
Text State │
│ │ │
▼ ▼ │
Voice TTS Telegram │
│ Voice │
└──────────┬───────┴────────────────────┘
[ThingSpeak]
[Dashboard]

39. Example n8n Pseudocode

TRIGGER:
Receive ESP32 data
VALIDATE:
Is device authenticated?
Is payload valid?
PROCESS:
Calculate/verify:
- voltage
- current
- power
- temperature
- status
SAFETY:
If critical threshold:
critical = true
AI:
Analyze event
IF critical:
Send Telegram text
Generate voice message
Send Telegram voice
Log event
ELSE IF warning:
Send Telegram text
Log event
ELSE:
Log normal measurement
ALWAYS:
Update dashboard
Store historical data
Update ThingSpeak

40. Database Structure

For a more professional project, replace Google Sheets as the primary database with a proper time-series or relational database.

Example:

TABLE power_readings
id
device_id
timestamp
voltage
current
power
energy
temperature
frequency
status
event
severity

Google Sheets can then be used as a reporting/export layer.


41. Communication Protocol Options

You have several choices.

Option A — HTTP

ESP32 → HTTP POST → n8n

Simple and easy for an academic project.

Option B — MQTT

ESP32
MQTT Broker
n8n

Better suited to scalable IoT systems.

Option C — HTTP + MQTT

ESP32
├── MQTT → IoT data
└── HTTPS → commands/API

For a final-year project, MQTT + n8n can make the architecture look more like a real IoT platform, while HTTP webhook integration is easier to demonstrate.


42. Recommended Final Architecture

I would recommend:

┌───────────────────┐
│ Electrical Sensors│
└─────────┬─────────┘
┌────────────┐
│ ESP32 │
│ Edge Node │
└─────┬──────┘
MQTT / HTTPS
┌────────────┐
│ n8n │
│ Automation │
└─────┬──────┘
┌───────────┼────────────┐
▼ ▼ ▼
Rule Engine AI Agent Database
│ │ │
│ │ ▼
│ │ Google Sheets
│ │
└─────┬─────┘
Decision Layer
┌─────────┼───────────┐
▼ ▼ ▼
Dashboard Telegram ThingSpeak
┌────┴────┐
▼ ▼
Text Voice

43. Project Demonstration

Your final demonstration can contain five test cases.

Test 1 — Normal condition

Voltage = normal
Current = normal
Temperature = normal
Result:
🟢 NORMAL

Test 2 — Over-current

Artificially create a safe simulated/low-voltage over-current condition.

Current > configured threshold
Result:
🟡/🔴 ALERT

Expected:

ESP32 → n8n → AI → Telegram

Test 3 — Over-temperature

Heat the sensor using a controlled test method.

Temperature > threshold

Expected:

CRITICAL
Telegram text
Telegram voice
Dashboard red status
Event stored

Test 4 — Internet failure

Turn off Wi-Fi.

Expected:

ESP32 continues local monitoring
Local safety logic continues
Cloud communication unavailable

Then reconnect.

Wi-Fi restored
Data synchronization

Test 5 — Recovery

Return the parameters to normal.

Expected:

FAULT
Monitoring
Normal condition
Recovery event
Telegram notification
Dashboard GREEN

44. Flowchart

START
Initialize ESP32
Connect Wi-Fi
Read Sensors
Validate Readings
Calculate Parameters
┌─────────────────────┐
│ Safety Threshold OK?│
└──────────┬──────────┘
YES │ NO
│ │
│ ▼
│ Critical
│ Event
│ │
│ ▼
│ Local Protection
│ │
└────┤
Send IoT Data
n8n
AI Analysis
┌──────┴───────┐
▼ ▼
Normal Abnormal
│ │
│ ▼
│ Telegram Alert
│ │
│ ▼
│ Voice Notification
└───────┬──────┘
Store Data
Update Dashboard
Repeat

45. Schematic-Level Architecture

For the academic schematic, use:

ESP32
┌───────────────┐
│ │
Voltage Sensor ─┤ ADC │
│ │
Current Sensor ─┤ ADC │
│ │
Temp Sensor ────┤ GPIO/I²C │
│ │
Relay Driver ◄──┤ GPIO │
│ │
│ Wi-Fi │
└───────┬───────┘
│ Wi-Fi
Internet
n8n Server
┌──────────────┼──────────────┐
│ │ │
▼ ▼ ▼
Google Sheets ThingSpeak AI Agent
│ │
└──────────────┬──────────────┘
Web Dashboard
Telegram
/ \
▼ ▼
Text Voice

For the actual electrical side, keep the sensor interface electrically isolated and use proper protection/isolation components. Do not put an ESP32 breadboard circuit directly across mains.


46. Project Modules

You can divide the project into 10 modules:

Module 1 — Sensor Module

Measures:

Voltage
Current
Temperature
Power
Energy
Frequency

Module 2 — ESP32 Edge Module

Sensor acquisition
Filtering
Local processing
Safety logic

Module 3 — IoT Communication Module

Wi-Fi
MQTT/HTTP
Cloud communication

Module 4 — n8n Automation Module

Data ingestion
Processing
Routing
Notifications

Module 5 — AI Agent Module

Event interpretation
Fault classification
Recommendation generation

Module 6 — Cloud Data Module

Google Sheets
ThingSpeak
Database

Module 7 — Web Dashboard

Live values
Charts
Device status
Alarm history

Module 8 — Telegram Module

Text alert
Voice alert
Recovery alert

Module 9 — Protection Module

Alarm
Relay/contactor interface
Emergency state

Module 10 — Security Module

Authentication
HTTPS
Secrets
Device identity

47. Expected Advantages

The system provides:

  • real-time monitoring
  • remote monitoring
  • automatic fault detection
  • AI-assisted analysis
  • automatic notifications
  • voice alerts
  • historical data
  • web visualization
  • IoT cloud integration
  • automation
  • local edge protection
  • scalable architecture

48. Limitations

The project should acknowledge:

  1. ESP32 ADC measurements require calibration.
  2. Low-cost sensors may have measurement errors.
  3. Internet connectivity can fail.
  4. AI decisions may be probabilistic.
  5. Cloud services can become unavailable.
  6. Google Sheets is not ideal for high-frequency telemetry.
  7. Real electrical installations require professionally designed protection.
  8. A prototype should not be treated as a certified grid-protection device.

49. Future Enhancements

You can extend the project with:

Predictive maintenance

Historical current
+
Temperature
+
Power patterns
ML model
Failure prediction

Load forecasting

Historical consumption
ML model
Predicted future load

Anomaly detection

Normal power signature
AI/ML model
Unexpected pattern
Alert

Multiple ESP32 nodes

ESP32 #1 ─┐
ESP32 #2 ─┤
ESP32 #3 ─┼──► MQTT ─► n8n ─► AI
ESP32 #4 ─┤
ESP32 #5 ─┘

This turns the project into a distributed smart-grid monitoring platform.


50. Final-Year Project Workflow

A practical implementation sequence is:

STEP 1
Build ESP32 sensor prototype
STEP 2
Read voltage/current/temperature
STEP 3
Calibrate sensors
STEP 4
Implement local safety rules
STEP 5
Connect ESP32 to Wi-Fi
STEP 6
Create n8n webhook/MQTT workflow
STEP 7
Send ESP32 telemetry to n8n
STEP 8
Add Google Sheets logging
STEP 9
Add ThingSpeak visualization
STEP 10
Build web dashboard
STEP 11
Create Telegram bot
STEP 12
Add Telegram text alerts
STEP 13
Add text-to-speech
STEP 14
Send Telegram voice alerts
STEP 15
Add AI agent
STEP 16
Add event classification
STEP 17
Test fault scenarios
STEP 18
Add authentication/security
STEP 19
Perform reliability testing
STEP 20
Prepare final demonstration

51. Suggested Project Folder Structure

AI-Smart-Power-Grid/
├── ESP32/
│ ├── main.cpp
│ ├── sensors.h
│ ├── sensors.cpp
│ ├── safety.h
│ ├── safety.cpp
│ ├── wifi_manager.h
│ └── cloud_manager.h
├── n8n/
│ ├── workflow.json
│ └── README.md
├── dashboard/
│ ├── index.html
│ ├── style.css
│ └── app.js
├── telegram/
│ └── bot_configuration.md
├── ai/
│ ├── agent_design.md
│ └── prompts.md
├── database/
│ └── schema.sql
├── documentation/
│ ├── abstract.md
│ ├── introduction.md
│ ├── methodology.md
│ ├── architecture.md
│ ├── testing.md
│ └── conclusion.md
└── README.md

52. Final Project Concept

The complete project can be summarized as:

AI SMART POWER GRID
┌────────────────┐
│ Electrical │
│ Sensors │
└───────┬────────┘
┌────────────────┐
│ ESP32 EDGE │
│ INTELLIGENCE │
└───────┬────────┘
Local Safety Logic
Wi-Fi/MQTT
┌────────────────┐
│ n8n │
│ AUTOMATION │
└───────┬────────┘
┌─────────┼──────────┐
▼ ▼ ▼
AI Agent Database IoT Cloud
│ │ │
└────┬────┴──────────┘
WEB DASHBOARD
TELEGRAM BOT
/ \
▼ ▼
TEXT VOICE

Core innovation

The strongest way to present the project is not simply "ESP32 sends data to Telegram."

Instead, present it as:

An edge-to-cloud agentic IoT safety platform in which the ESP32 performs real-time sensing and deterministic local protection, n8n orchestrates the IoT workflow, an AI agent interprets abnormal events, cloud services maintain historical telemetry, and Telegram provides real-time text and voice communication to the operator.

That framing makes the project substantially stronger for a final-year engineering project, mini-project, prototype demonstration, or research-oriented IoT project.

Safety note: For your physical prototype, demonstrate switching/protection with an isolated low-voltage load unless the mains side has been designed, enclosed, protected, and tested by a qualified electrical professional. The ESP32, breadboard, USB wiring, and ordinary hobby relay modules should not be treated as mains-rated protection equipment.

No comments:

Post a Comment