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.

Comments