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

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 Board | 1 |
| ACS712 Current Sensor | 1 |
| ZMPT101B Voltage Sensor | 1 |
| Relay Module | 1 |
| OLED Display | 1 |
| Breadboard | 1 |
| Jumper Wires | Several |
| 5V Adapter | 1 |
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
- Create ThingSpeak account.
- Create New Channel.
- Add Fields:
- Voltage
- Current
- Power
- Energy
- Copy API Key.
- Paste API Key into ESP32 code.
Google Sheets Integration
| Date |
Time |
Voltage |
Current |
Power |
Energy |
Prediction |
Telegram Bot Setup
- Open BotFather.
- Create Bot using /newbot.
- Copy Bot Token.
- Get Chat ID.
- 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 Accuracy | 95-98% |
| Forecast Accuracy | 85-95% |
| Cloud Update | 15 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.
Comments
Post a Comment