ESP32/IoT B.Tech/Diploma Beginner

IoT AC Energy Meter with PZEM-004T & ESP32 WebServer

IoT based AC Energy Meter with PZEM-004T & ESP32 WebServer to display Voltage, Current, Power, Energy, Frequency, Power Factor on Web page

  • Suitable forB.Tech/Diploma ESP32/IoT students
  • Build time1-2 weeks
  • LevelBeginner
  • Available atAjvika Labs, Kakinada

About this project

Overview
In this project, we will create an
IoT-based AC Energy Meter
using the
ESP32 microcontroller
and the
PZEM-004T module
, a high-precision AC power monitoring solution. Unlike traditional Arduino-based setups with LCD displays, this project uses the ESP32’s Wi-Fi capabilities to host a
local web server
. The Webserver dynamically displays
voltage, current, power, energy, frequency
, and
power factor
on a responsive
webpage
. Data updates in
real time
without requiring manual page refreshes.
Earlier energy meter projects, such as those using the
ZMPT101B voltage sensor
and
SCT-013 current sensor
, are excellent for learning but lack precision. The
PZEM-004T
addresses this gap with industrial-grade accuracy.
You may take a look at the previous energy meter projects:
GSM-Based Prepaid Energy Meter
IoT DC Energy Meter using INA226 & ESP32
IoT AC Energy Meter with ESP32 & Blynk
Energy Meter using ESP32 & HMI Display
The
PZEM-004T Multifunction AC Digital Meter
communicates via
Modbus-RTU over RS485
, enabling reliable measurement of:
Voltage (V)
Current (A)
Active Power (W)
Energy (kWh)
Frequency (Hz)
Power Factor
In this project, the ESP32 reads data from the
PZEM-004T
using
ModbusMaster
library. The
ESPAsyncWebServer
and
AsyncTCP
libraries create a non-blocking web server. The webpage uses
JavaScript
to fetch live data from the ESP32 without reloading, ensuring smooth
real-time visualization
. By the end, you’ll have a robust
IoT energy meter
ready for home automation, industrial monitoring, or smart grid applications.
Bill of Materials
We need following components to build this IoT AC Energy Meter project. You can purchase all the components from the given links.
S.N.
Components Name
Quantity
Purchase Link
1
ESP32 Board
1
Amazon
AliExpress
2
PZEM-004T AC Meter Module
1
Amazon
AliExpress
3
Connecting Wires
10
Amazon
AliExpress
4
Breadboard
1
Amazon
AliExpress
PZEM-004T Multifunction AC Digital Meter
The
PZEM-004T
is a compact,
single-phase AC power
monitoring module designed to measure electrical parameters such as
voltage
(80–260V),
current
(up to 100A via external CT), active
power
energy
consumption (kWh),
frequency
, and
power factor
Fig: PZEM-004T V3.0
It communicates via
Modbus-RTU protocol
over TTL serial (), making it easy to interface with microcontrollers like
Arduino
or
ESP32
. With built-in galvanic isolation and a
non-invasive current transformer
, it prioritizes safety. It is widely used in IoT applications, smart metering, and home automation projects.
PZEM-004T V3.0 Feature
Voltage:
80–260V, 0.1V resolution, 0.5% accuracy
Current:
0–10A (10A model), 0–100A (100A model), 0.001A resolution, 0.5% accuracy
Active Power:
0–2.3kW (10A model), 0–23kW (100A model), 0.1W resolution, 0.5% accuracy
Power Factor:
0.00–1.00, 0.01 resolution, 1% accuracy
Frequency:
45–65Hz, 0.1Hz resolution, 0.5% accuracy
Active Energy:
0–9999.99kWh, 1Wh resolution, 0.5% accuracy, resettable via software
Over Power Alarm:
Settable threshold, triggers alarm on exceedance
Communication:
RS485 (UART to RS485), 9600 baud, 8N1
Open CT & Close CT
Both
Close CT
and
Open CT
are 100A current transformers (Class 1.5 accuracy) compatible with the PZEM-004T module.
Fig: PZEM-004T Open CT & Close CT
The
Closed Current Transformer (CT) version
of the PZEM-004T comes with a built-in, non-detachable CT, ensuring accurate and stable measurements. It is ideal for fixed installations where the sensor remains permanently connected to the measured circuit.
The
Open Current Transformer (CT) version
features a detachable clamp-type CT, allowing easy installation without disconnecting wires. This is useful for retrofitting or temporary monitoring applications where quick and flexible deployment is required.
Pinout of PZEM-004T V3.0
The
PZEM-004T
is an energy monitoring module that communicates via
UART (RS485)
and has the following pin configuration:
1. Power & Measurement Pins:
L (Live) & N (Neutral):
Connect to AC mains for voltage measurement and module power.
CT+ & CT-:
Connect to the current transformer (CT) for current measurement.
2. Communication Pins (TTL Serial or RS485):
5V:
Power supply for the module (external 5V required).
GND:
Ground reference for communication.
TX (Transmit):
Sends data to the microcontroller.
RX (Receive):
Receives data from the microcontroller.
Module TTL Interface Note:
This module’s TTL interface is
passive
and requires an external
5V power supply
. All four pins (5V, RX, TX, GND) must be connected for proper communication. Operating temperature range:
-20°C to +60°C
Communication Protocol of PZEM-004T V3.0
1. Physical Layer Protocol
Uses
UART to RS485
communication interface
Baud rate:
9600
8 data bits
1 stop bit
no parity
2. Application Layer Protocol
Uses
Modbus-RTU
protocol
Supported function codes:
0x03
(Read Holding Register)
0x04
(Read Input Register)
0x06
(Write Single Register)
0x41
(Calibration – internal use only, requires password 0x3721)
0x42
(Reset Energy)
3. Addressing
Slave address range:
0x01 – 0xF7
0x00
: Broadcast address (slave does not reply)
0xF8
: General address (for single-slave environments and calibration)
4. Reading Measurement Results
Master command format (8 bytes):
Slave Address + 0x04 + Register Address (High + Low) + No. of Registers (High + Low) + CRC (High + Low)
Correct :
Slave Address + 0x04 + No. of Bytes + Register Data + CRC
Error :
Slave Address + 0x84 + Error Code + CRC
0x01
: Illegal function
0x02
: Illegal address
0x03
: Illegal data
0x04
: Slave error
5. Register Mapping
Register Address
Description
Resolution
0x0000
Voltage
0.1V
0x0001-0x0002
Current (Low & High)
0.001A
0x0003-0x0004
Power (Low & High)
0.1W
0x0005-0x0006
Energy (Low & High)
1Wh
0x0007
Frequency
0.1Hz
0x0008
Power factor
0.01
0x0009
Alarm status (0xFFFF = Alarm, 0x0000 = No Alarm)
For example, to read
10 registers from slave address 0x01
, the master sends:
0x01 + 0x04 + 0x00 + 0x00 + 0x00 + 0x0A + CRC
Indicator Lights of PZEM-004T V3.0
The module has multiple LEDs to indicate power, pulse, and communication status:
Fig: Indicator Lights of PZEM-004T V3.0
Power Indicator Light:
Shows that the module is powered and operational.
Pulse Indicator Light:
It b
links based on active energy measurement. The h
igher blinking rate indicates higher power consumption.
TX Communication Light:
Blinks when the module transmits data via RS485.
RX Communication Light:
Blinks when the module receives data from the master device (e.g., Arduino, ESP32).
Refer to
PZEM-004T Datasheet
for more information.
Interfacing PZEM-004T with ESP32 Microcontroller
Lets interface the PZEM-004T AC Energy Meter Module with ESP32 Microcontroller and read the energy meter data. For that, we will first connect the PZEM-004T with ESP32 and then write a C++ Code to fetch the PZEM-004T data.
Circuit Diagram & Connections
The following is the
connection diagram
between
PZEM-004T
&
ESP32
which looks simple and straightforward.
Fig: PZEM-004T & ESP32 Circuit & Connection
Connect the PZEM-004T’s
5V
and
GND
to ESP32’s 5V and GND for power. Link
TX
(PZEM) →
RX2
(ESP32 pin 16) and
RX
(PZEM) →
TX
(ESP32 pin 17) for serial communication.
Fig: Interfacing PZEM-004T with ESP32
Connect the circuit on breadboard as per circuit diagram above.
Wire the
live (L)
and
neutral (N)
of your AC supply (120V/220V) to the PZEM’s
AC input terminals
(labeled “L” and “N”).
Fig: Current Transformer Connection
For Open CT (split-core): Clamp the CT around the live wire of the AC circuit you want to monitor (do NOT clamp neutral).
For Close CT (solid-core): Disconnect the circuit, thread the live wire through the CT’s core, and reconnect.
Caution
:
Isolate AC input (120/220V) wiring from Arduino circuits for safety.
Source Code/Program
Lets write a
C++ Code
to establish a
Serial Communication
between ESP32 & PZEM-004T Energy Meter Module. But before moving to the coding part, first install the
PZEM-004T A

Technologies used

ESP32ArduinoBlynkBLEGSMLCDINA226PZEM-004TJavaJavaScriptUARTADC

Hardware components

  • ESP32
  • Arduino
  • INA226
  • PZEM-004T

Software & tools

  • Blynk

What you get

  • Working project / hardware kit, tested before delivery
  • Complete source code with explanation
  • Project demo and guidance for your viva
  • Project report, PPT and IEEE paper support (on request)
Delivery & Payment
Delivery takes a minimum of two weeks from the date your inquiry is confirmed. Payment is in two parts: • 50% advance to start the project • Remaining 50% before delivery Note: • Documentation and PPT are not included by default • If you need documentation/PPT, it can be arranged for extra time and cost We'll confirm the exact timeline and cost with you after reviewing your requirements.