CC Blog • Projects

Build a Smart Energy Meter to Track Home Power Use

Using an ESP32 Dev Kit and PZEM-004T Energy Sensor Module

Energy monitoring systems can be valuable in both industrial and home applications. In this article, Maheswaran describes how he combined IoT and embedded systems to provide an efficient, reliable solution for tracking household electricity consumption in real time, with data sent continually to an app on an Android smartphone.


  • How does an ESP32-based smart energy meter work?
  • What electrical parameters can be monitored in real time?
  • How does Wi-Fi and cloud integration enable remote tracking?
  • How accurate is a DIY IoT energy monitoring system?
  • What are the key steps to build and deploy the system?
  • ESP32
  • PZEM-004T
  • Adafruit IO
  • Flutter
  • MQTT
  • Arduino IDE
  • FreeCAD
  • Espressif | espressif.com

After noticing a sudden spike in my home electricity bill, I wanted to know exactly when and how my home was using more power. So, I built a Smart Energy Meter that tracks real-time energy consumption using easy-to-obtain, open-source tools.

The setup uses an ESP32 and a PZEM-004T-100A (V3.0) sensor module to measure voltage, current, power, frequency, power factor, and total energy consumption. The system is powered from the mains using a 230V-to-5V converter and shares all readings to the Adafruit IO cloud. A Flutter mobile app then displays these parameters on my smartphone, helping me identify high-usage times and appliances that draw excess power. The installed meter with Flutter UI is shown in Figure 1.

Figure 1
Smart Energy Meter installed in home with Flutter user interface.
Figure 1
Smart Energy Meter installed in home with Flutter user interface.

This simple yet powerful project shows how IoT and mobile integration can make energy tracking more transparent, personalized, and practical for DIY makers and homeowners.

SYSTEM OVERVIEW

The smart energy meter system integrates embedded control, power measurement, and IoT communication into a compact and reliable platform for real-time energy monitoring. The overall functional flow is shown in the block diagram in Figure 2. The system starts with a 230V-AC-to-5V DC Hi-Link power module (Figure 3), which supplies regulated power to both the ESP32 controller and the PZEM-004T energy measurement module. The PZEM-004T, along with a current transformer (CT), measures voltage, current, power, power factor, frequency, and energy consumption of the connected load.

Figure 2
Block diagram of Smart Energy Monitoring System.
Figure 2
Block diagram of Smart Energy Monitoring System.
Figure 3
The Hi-Link 230V AC-to-5V DC converter module.
Figure 3
The Hi-Link 230V AC-to-5V DC converter module.

The ESP32 processes these measurements and transmits the data to the Adafruit IO cloud over Wi-Fi for online visualization. A Flutter-based mobile application running on a smartphone retrieves this data from the cloud and presents it in a user-friendly interface, allowing users to monitor real-time power usage and identify high-consumption patterns. Each component in this system performs a specific role, as described below.

Power Supply Unit

The power supply section serves as the foundation of the intelligent energy meter system, ensuring the safe and stable operation of all electronic components. The circuit is powered directly from the 230V AC mains, which is converted to a regulated 5V DC output using a Hi-Link 230V AC-to-5V DC converter module (Figure 3). This compact, isolated module provides up to 1A of current, sufficient to power both the ESP32 controller and the PZEM-004T energy measurement module.

The ESP32 typically draws between 200mA to 300mA during normal operation, with peaks up to 500mA during Wi-Fi transmission, and the sensor module consumes about 30mA, keeping the total current draw well within the supply capacity. The converter’s built-in electrical isolation provides an additional layer of safety, separating the high-voltage AC input from the low-voltage control circuitry. The entire power section is enclosed in a non-conductive housing to prevent accidental contact with live terminals, making the design compact, efficient, and safe for continuous operation in home environments.

ESP32 Development Kit

The ESP32 WROOM development kit (Figure 4) serves as the central processing and communication unit of the smart energy meter system. It acquires measurement data from the sensor module, processes the readings, and transmits the information to the Adafruit IO cloud via Wi-Fi.

Figure 4
The ESP-WROOM-32 Development Kit.
Figure 4
The ESP-WROOM-32 Development Kit.

Although the ESP32 chip itself operates at 3.3V logic level, the development board includes an onboard 3.3V voltage regulator, which allows it to be powered directly from a 5V supply through the VIN or 5V pin. This regulator ensures a stable 3.3V output for the microcontroller and its peripherals, simplifying power integration with other 5V-based modules in the circuit.

In operation, the ESP32 communicates with the sensor module through a UART interface, periodically reading parameters such as voltage, current, power, power factor, and energy. The acquired data is formatted and sent to the Adafruit IO cloud dashboard over Wi-Fi, using the MQTT protocol.

The ESP32’s dual-core processor efficiently handles both data acquisition and wireless communication tasks, ensuring reliable real-time performance. Its built-in Wi-Fi capability eliminates the need for external communication hardware, making the design compact and cost-effective. Overall, the ESP32 acts as the intelligent bridge between the sensing hardware and the cloud platform, enabling continuous and remote energy monitoring.

PZEM-004T Power Monitoring Module

The Peacefair PZEM-004T-100A (V3.0) module (Figure 5) is the central sensing unit in the smart energy meter system. It measures key electrical parameters, including voltage, current, power, frequency, power factor, and total energy consumption. The module operates from a 5V DC supply derived from the system’s regulated power source and interfaces with the ESP32 controller via a UART link.

Figure 5
The Peacefair PZEM-004T-100A (V3.0) power monitoring module.
Figure 5
The Peacefair PZEM-004T-100A (V3.0) power monitoring module.

Current is measured using an external current transformer (CT), which enables non-invasive sensing of AC flowing through the load. The CT provides electrical isolation between the high-voltage circuit and the low-voltage control electronics, ensuring user safety and reliable data acquisition. This sensor measures up to 100A in load. It internally measures voltage via a built-in voltage divider and isolation circuitry, combining current and voltage measurements to accurately calculate power and energy.

This module continuously updates the measured data and transmits it digitally to the ESP32 for further processing and cloud upload.

PARAMETERS MEASURED

Voltage (V):

1) The potential difference between the live and neutral lines of the AC supply.

2) The system continuously monitors the RMS (Root Mean Square) voltage value to ensure the supply remains stable, typically around 230V AC for domestic applications.

3) Sudden drops or spikes in voltage can indicate wiring issues or grid fluctuations.

Current (A):

1) The amount of electricity flowing through the load connected to the system.

2) The current transformer in the sensor module accurately measures current draw in amperes.

3) Monitoring current helps detect overloading or abnormal consumption in electrical appliances.

Power (W):

1) The rate at which electrical energy is transferred or consumed over time by the connected load.

2) It is measured in watts (W), calculated as the product of voltage, current, and power factor (P = V × I × PF).

3) Real-time power monitoring helps identify energy-hungry devices and improves load management efficiency.

Power Factor (PF):

1) The ratio of real power (the power that does the work) to apparent power (the total power supplied) in the circuit, showing how efficiently electricity is being used.

2) The value ranges from 0 to 1, where 1 represents maximum efficiency.

3) Low power factor values may suggest inductive loads or poor power quality, which can lead to energy losses.

Energy Consumption (kWh):

1) The total electrical energy used over time, expressed in kilowatt-hours (kWh) or units.

2) The PZEM-004T module integrates power readings over time to calculate cumulative energy usage.

3) This parameter is essential for billing and long-term consumption analysis.

Frequency (Hz):

1) The rate at which an AC waveform oscillates between positive and negative values, expressed as AC voltage cycles per second (Hertz), It typically is 50Hz in most regions.

2) Monitoring frequency ensures grid health and stability—the balance between power generation and consumption. Deviations can indicate power supply disturbances or generator instability.

WI-FI COMMUNICATION

The ESP32’s built-in Wi-Fi transceiver provides a seamless and efficient communication link between the smart energy meter and the cloud-based monitoring platform. In this system, the ESP32 connects to a WiFi network and transmits real-time measurement data to the Adafruit IO cloud using the MQTT protocol.

Each set of readings, including voltage, current, power, power factor, frequency, and total energy, is periodically published to dedicated data feeds on the Adafruit IO dashboard (Figure 6). This enables continuous data logging, live graph updates, and remote accessibility from any location.

Figure 6 Example of readings (voltage, current, power, power factor, frequency, and total energy) published periodically to dedicated data feeds on the Adafruit IO dashboard.
Figure 6
Example of readings (voltage, current, power, power factor, frequency, and total energy) published periodically to dedicated data feeds on the Adafruit IO dashboard.

The use of Wi-Fi with cloud integration allows users to monitor their home energy consumption from anywhere, using an Internet-connected device. The companion Flutter-based mobile application retrieves this data directly from Adafruit IO and presents it in a clean, user-friendly interface. This approach eliminates the need for direct device pairing or local networking setup, making the system simple to deploy and scalable for multiple installations.

Wi-Fi communication was chosen over alternatives such as Bluetooth or RF modules due to its longer range, higher data throughput, and stable connectivity for continuous real-time updates. Once powered on, the ESP32 automatically connects to the configured Wi-Fi network and begins publishing measurement data to the cloud. This design ensures that the energy monitoring system remains reliable, autonomous, and always accessible, enabling users to keep track of their energy usage effortlessly through the cloud dashboard or mobile app.

ADAFRUIT IO CLOUD PLATFORM

The free version of Adafruit IO was used in this project. Adafruit IO is a cloud-based Internet of Things (IoT) platform designed for data connectivity, monitoring, and visualization of IoT devices. In this project, Adafruit IO serves as the central data hub for receiving, storing, and displaying real-time energy parameters transmitted from the ESP32 controller. The platform supports both MQTT and HTTP communication protocols, ensuring reliable integration with the ESP32 and making it well-suited for continuous, low-power IoT applications.

Each electrical parameter is assigned to a separate data feed within the Adafruit IO account. These feeds are displayed in a customizable dashboard that uses widgets such as gauges, line charts, and numeric indicators to visualize real-time and historical power usage trends. The dashboard allows users to interpret variations in energy consumption and identify high-demand periods easily.

Beyond visualization, Adafruit IO also provides data logging and cloud storage, enabling users to perform long-term analysis of power usage patterns. This system uses the API through a Flutter-based mobile application that fetches cloud data and displays it in a user-friendly interface (Figure 7).

— ADVERTISMENT—

—Advertise Here—

Figure 7
Adafruit IO energy meter dashboard.
Figure 7
Adafruit IO energy meter dashboard.
FLUTTER MOBILE APPLICATION

To provide users with easy and real-time access to home energy data, a dedicated mobile application was developed using Flutter, Google’s cross-platform UI development framework. The app communicates with the Adafruit IO cloud platform through REST API calls, enabling users to view live measurements transmitted from the ESP32-based smart energy meter. All key parameters are displayed in a clean, text-based dashboard for quick, clear interpretation, without the need for complex gauges or charts.

The mobile interface is designed with simplicity and responsiveness in mind, ensuring smooth performance and easy navigation even on entry-level Android devices. I developed the application for Android, but since it was built with Flutter, the same source code can be easily ported to iOS as well.

This mobile app provides a practical and lightweight companion to the hardware, allowing homeowners to monitor their energy usage anytime, anywhere. By integrating cloud data retrieval, real-time updates, and a user-friendly layout, the Flutter app completes the IoT ecosystem of the smart energy meter, turning raw sensor data into accessible insights for effective energy management.

ENCLOSURE DESIGN

For this project, a custom 3D-printed enclosure was designed to securely house and protect all electronic components used in the smart energy monitoring system. The design was developed using FreeCAD, an open-source 3D modeling software that enabled precise alignment of the ESP32 development board, PZEM-004T energy sensor, and Hi-Link AC–DC converter module. The enclosure was fabricated using PETG filament.

The complete enclosure setup comprises an enclosure base, a press-fit top lid, and screw mounting pads. Two ventilation slots are provided to prevent heat buildup from the Hi-Link converter and the ESP32 during prolonged operation.

This modular, 3D-printed design enhances the overall reliability and serviceability of the system and also simplifies maintenance and customization for future versions—such as integrating a display module or additional sensors for advanced energy analytics.

HARDWARE INTEGRATION AND ASSEMBLY

The complete schematic diagram of the smart energy monitoring system is shown in Figure 8. This project consists of four main sections: the microcontroller unit, the power supply unit, the sensing unit, and connectors.

Figure 8
Schematic diagram of the Smart Energy Monitoring System.
Figure 8
Schematic diagram of the Smart Energy Monitoring System.

The hardware was assembled on the double-sided dotted PCB, chosen for its flexibility, durability, and suitability for prototyping compact embedded systems. This configuration allowed easy placement, soldering, and routing of both power and communication lines while ensuring stable electrical connections between all the modules. Now, let’s look at the process for assembling the system.

Assembling the PCB and Hardware

Solder two 15-pin ESP32 Bergstik headers onto the PCB. Align them precisely to fit the ESP 32 Dev Kit, and ensure proper spacing for easy insertion.

Solder the 4-pin JST connector onto the PCB. It will serve as the communication link between the ESP32 and the PZEM-004T sensor module.

Mount and solder the Hi-Link power supply module onto the PCB. Ensure that the AC input and 5V output pins are oriented correctly for wiring and safety.

Mount and solder the 4-pin pluggable screw terminal onto the PCB. It is used for connecting the AC input line and current transformer connections.

Drill holes on the PCB at the required positions to mount the M3 standoffs. Insert the standoffs and secure them tightly using M3 nuts.

Assemble ESP32 and PZEM-004T modules. Insert the ESP32 Dev Kit into the female Bergstik headers, then mount the PZEM-004T module onto the standoffs and secure it with M3 screws, as shown in Figure 9.

Figure 9
PZEM-004T sensor module and ESP32 fixed to PCB.
Figure 9
PZEM-004T sensor module and ESP32 fixed to PCB.
Wiring and Connections

Make all the electrical connections according to the schematic diagram using insulated copper wires. Use higher-gauge AC voltage wires to ensure safety and reliability.

Perform final assembly and connections. First, connect the AC power line and current transformer wires from the PCB to the PZEM-004T sensor. Second, attach the 4-pin RMC connector from the PCB to the PZEM-004T. Third, plug the 4-pin pluggable screw terminal into its slot on the PCB.

Mounting the Hardware in the Enclosure

Fix the four screw mounting pads onto the enclosure base using super glue. These mounting pads create a small gap between the device and the wall surface, which helps prevent water accumulation or contact with the enclosure during rainy conditions, ensuring additional protection for the electronics.

Apply strong, double-sided adhesive tape to the bottom surface of the PCB. This tape will help securely attach the PCB to the enclosure base without the need for screws.

Carefully align and fix the PCB onto the enclosure base. The double-sided tape will hold the PCB firmly in place, providing both mechanical stability and vibration resistance.

Press the lid into place. The lid is designed for press-fit installation, allowing users to open and close it easily during installation or maintenance.

Mount the Smart Energy Meter at the desired location in your home. If needed, get help from a qualified electrician to ensure proper and safe wiring.

— ADVERTISMENT—

—Advertise Here—

FIRMWARE

The firmware for the system is developed under Arduino IDE. Its flow chart is shown in Figure 10. The firmware initializes the peripherals and Wi-Fi communication. Wi-Fi credentials for the router are provided in the code, as are the Adafruit IO key and feed variables. If Wi-Fi communication is established, it connects to the Adafruit cloud; otherwise, it will retry for connection. Once the cloud connection is established, sensor data is acquired and processed. Processed data is published to the Adafruit IO every 5 minutes (to comply with the limits of the free version of Adafruit IO).

Figure 10
Flow chart of system firmware.
Figure 10
Flow chart of system firmware.

Steps for: 1) uploading firmware for the ESP32 using Arduino IDE; 2) creating an Adafruit IO account, feeds, and dashboard; and 3) configuring Flutter and running the mobile app are given in Figures 11–13, respectively.

Upload Firmware Using Arduino IDE:

1) Configure ESP32 Board:

a) Open Arduino IDE

b) Go to File > Preferences

c) Paste this URL in Additional Board Manager URLs:
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

d) Go to Tools > Board > Boards Manager

e) Search for ESP32 by Espressif Systems and click “Install”

2) Install Required Libraries:

a)Go to Sketch > Include Library > Manage Libraries

b) In the Library Manager, search and install the following libraries: Adafruit IO Arduino, Adafruit MQTT Library ArduinoJson (if required)

3) Download and Configure the Source Code:

a) Download the source code from the Circuit Cellar Article Code and Files webpage

b) Open the .ino file in Arduino IDE

— ADVERTISMENT—

—Advertise Here—

c) Replace “Your_WiFi_Name” and “Your_WiFi_Password” with your actual Wi-Fi credentials

d) Replace “Your_Adafruit_IO_Username” and “Your_Adafruit_IO_Key” with your Adafruit IO credentials. You can find your key under My Key section in your Adafruit IO dashboard

4) Compile and Upload the Code:

a) Connect your ESP32 Dev Kit to your computer using a USB cable

b) In the Arduino IDE, go to:

• Tools > Board > ESP32 Dev Module

• Tools > Port, and select the correct COM port

c) Click the Verify button to compile the code

d) Click the Upload button to flash the firmware onto the ESP32

Wait for “Done Uploading” message.

Figure 11

Steps for uploading firmware using the Arduino IDE.

Create Adafruit IO Account, Feeds, and Dashboard:

1) Create an Adafruit IO Account, following the instructions for “Sign Up”
at https://io.adafruit.com

2) Create Feeds

a) After logging in, go to “Feeds” from the left menu

b) Click “New Feed”

c) Enter the name of the parameter (voltage, current, energy, and so on)

d) Add a short description (optional)

e) Click “Create”

f) Repeat this process to create feeds for all parameters

3) Create a Dashboard

a) Click on “Dashboards” from the left menu

b) Click “New Dashboard”

c) Enter a dashboard name (eg, Energy Monitoring) and description

d) Click “Create”

4) Add Gauge Blocks to Dashboard

a) Open the Dashboard you created

b) Click on “Create New Block”

c) Choose “Gauge” as the block type

d) Select the appropriate feed (such as voltage)

e) Click “Next”

f) Set the gauge range (for example, 0 to 300 for voltage )

g) Customize the following characteristics: Label (for example, “Voltage,Current,Power”), Units (V, A, W, and so on), Color

h) Repeat Steps 4b) to 4g) for each parameter

Figure 12

Steps for creating an Adafruit IO account, feeds, and dashboard.

Configure Flutter and Run the Mobile App:

1) Install Flutter SDK

a) Go to: https://flutter.dev/docs/get-started/install

b) Select your operating system (Windows, macOS, or Linux)

c) Download and extract the Flutter SDK to a folder (for example, C:\flutter)

d) Add the Flutter SDK’s bin directory to your system’s PATH

2) Install Visual Studio Code:

a) Download VS Code: https://code.visualstudio.com

b) Install the following extensions: Flutter & Dart

3) Install Android Studio (for Android SDK) at https://developer.android.com/studio

During setup, install:

a) Android SDK

b) Platform tools

c) Device emulator (optional)

Note: You don’t need to code in Android Studio; just use it to install SDK tools

4) Verify Installation

a) Open a terminal (Command Prompt or Terminal)

b) Run: Flutter Doctor

c) Fix any missing dependencies (such as “accept Android licenses”)

5) Set Up and Run Your App  

a) Open your Flutter project in VS Code
(See: https://docs.flutter.dev/deployment/android))

b) Make sure the main file is lib/main.dart

c) In terminal, run:flutter pub get Open lib/main.dart and replace your Adafruit IO username, key, and feed names

e) Connect your Android phone via USB with USB debugging enabled, or start an emulator

f) Run the app using: flutter run

6) Build a Release APK

a) In terminal (inside your project folder), run:flutter build apk –release

b) After the build completes, you’ll find the APK at:
build/app/outputs/flutter-apk/app-release.apk

c) Install or Share the APK

d) Copy app-release.apk to any Android phone and install it

e) If needed, upload it to the Play Store after signing the APK

f) For signing, follow Flutter docs: https://docs.flutter.dev/deployment/android

Figure 13

Configuring Flutter and running the mobile app on an Android smartphone. Since it is developed in Flutter, the same source code can be easily adapted for the iOS platform

TESTING AND RESULTS

After completing the hardware assembly and wiring, the smart energy monitoring system was powered up for functional verification. The Hi-Link 230V AC-to-5V DC power module delivered a stable output voltage, successfully powering both the ESP32 Dev Kit and the PZEM-004T energy monitoring module. Before connecting to the mains, all voltage levels and polarities were verified, using a multimeter to ensure safe operation.

Once powered, the ESP32 established stable serial communication with the PZEM-004T via the UART interface. The system continuously monitored the key electrical parameters—voltage, current, power, frequency, power factor, and total energy consumption. These readings were processed internally and uploaded to the Adafruit IO cloud platform at regular intervals.

Since this project uses the free version of Adafruit IO, which imposes a limit on daily data uploads, the ESP32 was programmed to transmit data once every 5 minutes rather than continuously publish. Despite the lower upload frequency, the sensor module continuously measures and internally updates all parameters in real time, allowing the ESP32 to fetch the latest values during each transmission cycle. This approach ensures efficient data usage without affecting accuracy or monitoring consistency.

The collected data was displayed on a custom Adafruit IO dashboard, featuring live feeds for all electrical parameters. Additionally, a Flutter-based mobile application fetched this data from the cloud and displayed it on my Android smartphone, enabling me to conveniently track my home energy consumption.

To validate accuracy, the system’s readings were compared with a standard household energy meter and a digital multimeter connected in parallel. The results showed a close match, with readings within ±1% to 2% of each other, confirming reliable measurement performance suitable for domestic energy tracking.

Overall, the system operated smoothly and consistently, with stable communication, accurate readings, and efficient cloud data management. The project successfully demonstrated an IoT-based energy monitoring solution that enables homeowners to track consumption trends, identify high-usage periods, and make informed decisions to manage their electricity bills effectively.

Monitoring Critical Data

The Smart Energy Monitoring System in this project combines IoT and embedded systems to provide an efficient and reliable solution for tracking household electricity consumption in real time. By integrating the ESP32 microcontroller with the PZEM-004T energy measurement module, the system accurately measures voltage, current, power, energy, frequency, and power factor the key parameters required for detailed energy analysis.

Using Adafruit IO as the cloud platform and a Flutter-based mobile application for visualization, users can easily access their home energy data at any time from any location. The data publishing interval of 5 minutes ensures compliance with the limits of the free Adafruit IO plan, while maintaining up-to-date insights into energy usage. Meanwhile, the sensor module continuously monitors and updates its internal measurements, ensuring accuracy and consistency in all readings.

Testing confirmed that the system’s readings closely matched the values from a standard household energy meter, validating its accuracy for residential applications. The modular design featuring a reliable Hi-Link power supply, organized PCB layout, and well-structured communication interface makes the system easy to replicate, modify, and scale.

Future enhancements could include support for three-phase monitoring, mobile notifications for overconsumption, or integration with smart home platforms for automated energy control.

RESOURCES
Espressif | https://www.espressif.com
Flutter | https://flutter.dev

SOURCES
https://www.espressif.com/en/products/socs/esp32
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
https://docs.flutter.dev/deployment/android
https://github.com/vortigont/pzem-edl/blob/main/docs/PZEM-003-Manual.pdf
https://robu.in/wp-content/uploads/2018/03/Peacefair-PZEM-004T-AC-Multi-function-Electric-Energy-Metering-Power-Monitor-1.pdf
https://robu.in/wp-content/uploads/2020/02/5W-series-power-module-V2.3.pdf

PUBLISHED IN CIRCUIT CELLAR MAGAZINE • JANUARY 2026 #426 – Get a PDF of the issue

Keep up-to-date with our FREE Weekly Newsletter!

Don't miss out on upcoming issues of Circuit Cellar.


Note: We’ve made the Dec 2022 issue of Circuit Cellar available as a free sample issue. In it, you’ll find a rich variety of the kinds of articles and information that exemplify a typical issue of the current magazine.

Would you like to write for Circuit Cellar? We are always accepting articles/posts from the technical community. Get in touch with us and let's discuss your ideas.

Sponsor this Article

Supporting Companies

Upcoming Events


Copyright © KCK Media Corp.
All Rights Reserved

Copyright © 2026 KCK Media Corp.

Build a Smart Energy Meter to Track Home Power Use

by Maheshwaran Sadasivam time to read: 16 min