This article details a DIY project for building a smart energy monitor using readily available and affordable components. The project leverages the PZEM-004T AC energy monitoring module, which provides real-time measurements of voltage, current, power, and energy consumption. This data is then processed and transmitted wirelessly via an ESP32 microcontroller (a Wemos D1 mini is used in this example, but other similar microcontrollers are also suitable). The simplicity of the design and the use of easily accessible components make this project ideal for hobbyists and makers of all skill levels.The project's data is sent to ThingSpeak, a free cloud-based IoT platform, enabling remote monitoring and analysis of energy usage. This platform allows for convenient visualization of the data through graphs and dashboards, providing valuable insights into energy consumption patterns. The inclusion of a web server on the ESP32 further enhances usability by facilitating easy configuration of parameters such as ThingSpeak API keys and customizable thresholds. This complete, cost-effective solution empowers users to gain a better understanding of their energy usage and potentially identify opportunities for conservation.
Pros And Cons
- Compact and lightweight
- Simple integration
- Compact and highly efficient
- Measures voltage, current, power, and energy consumption in real time
- Affordable
- Easy integration
- Supports serial communication protocols
- Suitable for low and high power applications
- Provides accurate measurements
- Compatible with microcontrollers like Arduino, ESP32, and Wemos D1 mini
- Can be clamped directly around an existing conductor without disconnecting it
- Quick and non-intrusive installation
Read more: AMI Meter Reading Guide: Understanding Your Smart Electricity Meter
PZEM-004T: The Core of Your Smart Energy System
The PZEM-004T is a compact and highly efficient AC energy monitoring module. It measures voltage, current, power, and energy consumption in real-time, making it perfect for DIY projects. Its affordability, ease of integration, and support for serial communication protocols like UART contribute to its popularity among hobbyists and makers.

This module is suitable for a wide range of applications, from low-power devices to high-power systems. Features such as cumulative energy monitoring and configurable thresholds enhance its versatility and safety. The PZEM-004T's accurate measurements make it an excellent choice for smart energy systems, solar power tracking, and home automation.

ESP32 Microcontroller: The Brains of the Operation
For this project, we utilize the ESP32 microcontroller (specifically, a Wemos D1 mini) due to its compact size, affordability, and ease of integration. Its built-in Wi-Fi capability simplifies data transmission to the cloud platform. While the ESP32 is a great choice, other microcontrollers like Arduino, ESP8266, or STM32 could also be used.

The ESP32 communicates with the PZEM-004T via serial communication (UART), receiving real-time energy data. This data is then processed and transmitted wirelessly to a cloud platform, allowing for remote monitoring and analysis of energy consumption patterns.

Connecting the Hardware: A Step-by-Step Guide
The process of connecting the components is straightforward, but caution is needed when dealing with mains voltage. It's crucial to correctly identify and connect the neutral and phase wires to both the load and the PZEM-004T. Using a clamp-type CT current transformer is simple to install without cutting wires.

Ensure the correct wiring to avoid electrical hazards. The wiring diagram provided in the video should be carefully followed. If you are not confident, seek assistance from a qualified electrician.

Software and Cloud Integration: ThingSpeak for Data Visualization
The project relies on several libraries for the ESP32, including ESP8266WiFi, WiFiManager, PZEM-004T, ThingSpeak, and ESP8266WebServer. These libraries provide the necessary functionalities for Wi-Fi connectivity, data acquisition, cloud communication, and web server functionality. It’s important to ensure proper setup of libraries in the Arduino IDE.

The ESP32 transmits energy data to ThingSpeak, a free cloud-based IoT platform. ThingSpeak provides tools to visualize the data through graphs and dashboards, allowing for easy monitoring and analysis of power consumption trends. The web server on the ESP32 allows for configuration of parameters like ThingSpeak API keys and thresholds.

Conclusion: A Powerful and Affordable DIY Solution
This DIY smart energy monitor provides a cost-effective and insightful way to track and understand your energy consumption. The combination of the PZEM-004T, ESP32, and ThingSpeak offers a powerful platform for real-time monitoring, data analysis, and potential energy savings. The ease of setup and readily available resources makes this project accessible to a wide range of users.

While this project provides valuable data, it's important to remember that it’s a DIY solution and might not have the same level of accuracy and safety features as commercial-grade energy monitoring systems. Always prioritize safety when working with mains voltage and seek professional help if needed. Overall, this project provides a strong foundation for understanding and optimizing your energy usage.