Build a Plug-In AC Energy Monitor with ESP32 and a PZEM-004T
- PZEM-004T V3.0 AC Energy Meter Module (with split-core CT, 100A)
- ESP32 Dev Board (30-pin)
- NEMA 5-15 Single-Gang Outlet Box and Cover Plate
- NEMA 5-15 Duplex Receptacle (15A, residential grade)
- 18 AWG Stranded Hookup Wire (for mains-side wiring inside the box)
- NEMA 5-15P Replacement Male Plug and Cord
- Wire Nuts / Wago Lever Connectors, Assorted
- 5V 2A USB Power Supply (for the ESP32, isolated from the mains path you're metering)
- Small Plastic Project Enclosure (to house the ESP32 outside the mains box)
- Heat Shrink Tubing Assortment
This site already has a whole-house energy monitor built with CT clamps around the main panel. This is the smaller, more targeted version: a single outlet-level power meter you plug a tool or appliance into and get real voltage, current, power, energy-over-time, power factor, and frequency readings from, reported to Home Assistant over WiFi. It's the right tool for answering "how much does my laser actually draw at idle vs. cutting," "is this old shop fridge worth replacing," or "which 3D printer in the farm is the power hog" — questions a whole-panel monitor can't answer on its own.
How It Works
The PZEM-004T is a small AC metering module built around a dedicated energy-metering IC with an integrated current transformer rated for up to 100A, isolated from its logic-side UART output. The module itself handles the dangerous part — it sits in-line with mains voltage and current — and talks to your ESP32 over a simple isolated serial connection at 5V logic (translated to 3.3V for the ESP32's UART), reporting voltage, current, active power, energy accumulated, frequency, and power factor as register values you poll over Modbus-RTU-like serial commands.
Parts List
- PZEM-004T V3.0 AC Energy Meter Module (with split-core CT, 100A)
- ESP32 Dev Board (30-pin)
- NEMA 5-15 Single-Gang Outlet Box and Cover Plate
- NEMA 5-15 Duplex Receptacle (15A, residential grade)
- 18 AWG Stranded Hookup Wire (for mains-side wiring inside the box)
- NEMA 5-15P Replacement Male Plug and Cord
- Wire Nuts / Wago Lever Connectors, Assorted
- 5V 2A USB Power Supply (for the ESP32, isolated from the mains path you're metering)
- Small Plastic Project Enclosure (to house the ESP32 outside the mains box)
- Heat Shrink Tubing Assortment
Wiring
The PZEM-004T's CT clamp is a split-core design on most versions, meaning it opens and closes around a single conductor — clamp it around just the hot (line) conductor feeding your outlet, never both hot and neutral together, or it will read near zero. The module's mains terminals connect to line and neutral directly (this module is designed to carry the full load current through its terminals, unlike a low-power sensor), and its 5V/TX/RX/GND header goes to the ESP32: 5V to the module's logic supply, TX/RX crossed to the ESP32's UART2 pins, and GND common.
Build this as two physically separate enclosures connected by a short low-voltage cable: a mains-rated box containing the outlet, the PZEM module, and all mains wiring, and a separate small plastic enclosure for the bare ESP32 board and its own USB power supply. Do not share a single enclosure unless you're confident in your mains isolation and have proper strain relief and clearance between mains and logic-side wiring — the PZEM module's logic header is isolated internally, but good practice is still to keep physical separation generous.
Firmware
ESPHome has a built-in pzemac platform component specifically for this module — point it at the correct UART pins and baud rate (9600 by default) and it exposes voltage, current, power, energy, frequency, and power factor as sensors automatically, no custom code required. Add a WiFi and API block as with any other ESPHome device, flash it, and it shows up in Home Assistant with all six values live within a minute of boot. From there, a simple Home Assistant automation can log daily energy totals per outlet, or alert you if a tool is pulling power while you thought it was off.
Safety
- This project carries mains voltage inside a box you build yourself — treat it with full electrical respect. Use a proper enclosure rated for the purpose, strain-relief every cord entry, and never leave bare mains conductors exposed or loosely twisted — use wire nuts or lever connectors rated for the gauge and current.
- Don't exceed the PZEM-004T's rated current (100A on most versions, but check your specific module — some are rated lower) or your outlet's 15A/20A breaker rating — this is a monitoring device, not a substitute for proper circuit protection.
- Test with a non-contact voltage tester before touching anything inside the box, every time, even after you've unplugged it — and never work on it while it's plugged in.
- Use a UL/CSA-listed outlet, plug, and cord rather than scavenged or unrated parts — this device sits between your tools and the wall, and its mains-handling components need to meet the same safety bar as any other extension cord or power strip.
Once you've got one built, it's cheap enough in parts cost to build two or three and rotate them around the shop — one on the laser, one on the air compressor, one on whatever you're currently trying to diagnose — rather than committing to a single permanent installation.