← Projects

IoT-Based Smart Energy Monitoring System Using ESP32 and PZEM-004T

12 Nov 202656 views
IoT-Based Smart Energy Monitoring System Using ESP32 and PZEM-004T
🖼 Gallery · 1 photo — click a photo to enlarge
Table of Contents
  1. Project Overview
  2. Project Features
  3. Required Components
  4. Circuit Connections
  5. Working Principle
  6. Software Requirements
  7. Applications
  8. Project Specifications

Project Overview

The IoT-Based Smart Energy Monitoring System is an intelligent electricity monitoring solution designed to measure and monitor real-time electrical parameters using an ESP32 microcontroller and PZEM-004T V3 energy meter module.

The system provides real-time monitoring of voltage, current, power, power factor, frequency, and energy consumption. It features a 1.3-inch OLED display for local monitoring and a web-based dashboard that allows users to access electrical data through a smartphone, tablet, or computer over Wi-Fi.

The system also includes configurable overload protection alerts, electricity cost calculation, power consumption history, and Wi-Fi configuration through a captive portal.

Project Features

  • Real-Time Energy Monitoring: Measures voltage, current, active power, and other electrical parameters.
  • Wi-Fi Connectivity: Connects to an existing Wi-Fi network for remote monitoring.
  • Web-Based Dashboard: Displays live electrical data through a responsive web interface.
  • OLED Display: Shows monitoring information on a 1.3-inch OLED screen.
  • Energy Consumption Tracking: Measures accumulated energy consumption in kWh.
  • Electricity Cost Calculation: Estimates electricity bills based on configurable tariff rates.
  • Overload Protection Alert: Activates an audible buzzer when power exceeds the configured limit.
  • Peak Power Monitoring: Records the maximum power consumption.
  • Power Trend Graph: Displays historical power consumption data.
  • Wi-Fi Setup Portal: Allows users to configure Wi-Fi without modifying the program.
  • Network Information: Displays the connected Wi-Fi network, signal strength, and IP address.
  • Energy Reset: Allows energy measurement data to be reset through the dashboard.

Required Components

No.Component NameQuantity
1ESP32 DevKit Development Board1
2PZEM-004T V3 Energy Meter Module1
31.3-inch OLED Display (SH1106, I2C)1
4Active Buzzer1
5Push Button1
6Resistors (1kΩ and 2kΩ)1 Set
7Connecting WiresAs Required
8AC Power Supply and Test LoadAs Required


Circuit Connections

ComponentPinESP32 Pin
PZEM-004T V3TXGPIO 16 (RX2)
PZEM-004T V3RXGPIO 17 (TX2)
PZEM-004T V3VCC5V
PZEM-004T V3GNDGND
OLED DisplaySDAGPIO 21
OLED DisplaySCLGPIO 22
OLED DisplayVCC3.3V
OLED DisplayGNDGND
BuzzerPositiveGPIO 25
BuzzerNegativeGND
Push ButtonSignalGPIO 0 (BOOT)


Important: Use an appropriate voltage divider on the PZEM TX signal before connecting it to the ESP32 RX pin. AC mains connections are hazardous and must be properly insulated and handled with suitable safety precautions.

Working Principle

The PZEM-004T V3 module measures electrical parameters from the AC supply and communicates with the ESP32 through UART communication.

The ESP32 processes the received measurements and performs several operations:


  1. Reads electrical data from the PZEM module.
  2. Updates the OLED display with real-time measurements.
  3. Sends measurement data to the built-in web server.
  4. Calculates electricity costs based on the configured tariff.
  5. Monitors power consumption against the overload threshold.
  6. Activates the buzzer when an overload condition is detected.
  7. Stores Wi-Fi credentials and system settings in ESP32 Preferences.

Users can connect to the device's Wi-Fi setup hotspot, configure their Wi-Fi credentials, and access the dashboard through the assigned IP address or http://energy.local.

Software Requirements

  • Arduino IDE
  • ESP32 Board Package
  • U8g2 Library
  • PZEM004Tv30 Library
  • Wi-Fi and WebServer Libraries (included with ESP32 framework)

Applications

  • Home electricity monitoring
  • Office and commercial energy monitoring
  • Electrical laboratory experiments
  • Power consumption analysis
  • Electricity cost estimation
  • IoT-based energy management systems

Project Specifications

ParameterSpecification
MicrocontrollerESP32
Energy MeterPZEM-004T V3
Display1.3-inch OLED
CommunicationUART, I2C, Wi-Fi
Web ServerESP32 Built-in WebServer
MonitoringReal-Time
Energy UnitkWh
Cost CurrencyBDT (Tk)
Firmware Version1.0.0


Developed by Micro Tronic

Build • Learn • Innovate

Note: The project currently provides monitoring and overload warning functionality. It does not automatically disconnect the AC load because no load-control relay is implemented in the supplied firmware.

Keep exploring

Recent Projects

View all →
Keep reading

Recent Blog Posts

View all →