Built a Three-Phase Power Meter for Home Energy Monitoring
This device can measure three-phase current, voltage, power, power factor, and energy consumption, with data uploaded to HomeAssistant for real-time monitoring of household electricity usage.
It uses three PZEM-004T power measurement modules, communicates via serial with an ESP32-C3, and uploads data to HomeAssistant over WiFi (self-hosted; I used a Raspberry Pi 4). The ESP32-C3 runs firmware developed with ESPHome.
This module can only measure the voltage between each phase and the neutral line, not the line-to-line voltage.
- Voltage measurement range: 80-260V
- Current range: 100A
- Measurement accuracy: 0.5%
You need to manually configure the addresses of the three PZEM-004T modules to 0x01, 0x02, and 0x03 using the provided software.
Warning: This project involves high voltage. Ensure safety and always operate with the power turned off!
For setup instructions on HomeAssistant + ESPHome, please refer to online tutorials.
Electronics & Embedded Systems Discussion Group: 2169025065
Hardware Images
Monitoring Dashboard
Circuit Diagram
PCB Layout
3D Enclosure Model
Downloads
Open-source project link: https://oshwhub.com/zeruns/san-xiang-dian-liang-dian-can-shu-shu-ju-cai-ji-san-xiang-dian-ya-dian-liu-gong-lv-gong-lv-yin-shu-yong-dian-liang
123 Cloud Drive (unlimited speed): https://url.zeruns.com/PbpP8 Code: jjRr
Baidu Cloud Drive: https://pan.baidu.com/s/1XCi1AY6M1G0weNuuVJu01w?pwd=qhrc Code: qhrc
Included files:
- 3D enclosure model
- Three-phase power meter Gerber files
- LCSC EDA project files
- PZEM-004T module manual
- PZEM-004T module configuration software
- ESPHome configuration files
Component Purchase Links
- LilyGO CORE-ESP32C3 Board: https://s.click.taobao.com/GsKSHxt
- PZEM-004T Module: https://s.click.taobao.com/cnHOHxt
- HLK-10M05 Power Module: https://s.click.taobao.com/quMNHxt
- 0805 Resistor/Capacitor Set: https://u.jd.com/fqAElBD
- AHT10 Sensor: https://s.click.taobao.com/WuhMHxt
- Recommended purchase from LCSC: LCSC Store
ESPHome Configuration File
#include "esphome.h"
#include "esphome/time/real_time_clock.h"
#include "esphome/sntp/sntp_component.h"
#include "esphome/core/time.h"
# Define the project name and friendly name
esphome:
name: powerbox
friendly_name: PowerBox
# Specify the development board and framework
platformio_options:
board_build.flash_mode: dio
board_build.mcu: esp32c3
esp32:
board: esp32-c3-devkitm-1
framework:
#type: esp-idf
type: arduino
# Enable logging
logger:
#hardware_uart: USB_SERIAL_JTAG
#level: DEBUG # defaults to DEBUG, NONE ERROR WARN INFO DEBUG VERBOSE VERY_VERBOSE
# Enable Home Assistant API with encryption key
api:
encryption:
key: "wZG666DZ5zsg6666Po6204w666kA+8u666soeGlKtBU=" # Replace with your own key
# Enable OTA updates with a password
ota:
password: "c368c9c66658f3433f6226667d4d2232" # Replace with your own key
network:
enable_ipv6: true
wifi:
ssid: "blog.zeruns.com" # WiFi network name
password: "123456789" # WiFi password
reboot_timeout: 60s # Reboot timeout if connection fails
# Enable AP mode as a fallback option
ap:
ssid: "Powerbox Fallback Hotspot"
password: "ZMpKTpHJ67EF"
# Manually set the IP address for use without a DHCP server
manual_ip:
static_ip: 192.168.0.201
gateway: 192.168.0.1
subnet: 255.255.255.0
dns1: 192.168.0.1
captive_portal:
# Enable web server to allow device control via HTTP
web_server:
port: 80
# Enable I2C communication interface
i2c:
- id: bus_a
sda: 4
scl: 5
scan: true
# Enable UART communication interface
uart:
rx_pin: 1
tx_pin: 0
baud_rate: 9600
# Enable Modbus protocol support
modbus:
# Configure sensors including temperature, humidity, and current sensors
sensor:
# AHT10 sensor configuration
- platform: aht10
variant: AHT20
i2c_id: bus_a
temperature:
name: "PowerBox-Temperature" # Temperature sensor name
id: AHT20_T
humidity:
name: "PowerBox-Humidity" # Humidity sensor name
id: AHT20_H
update_interval: 30s # Update interval: 30 seconds
- platform: pzemac
id: pzemac_A
address: 0x01
current:
name: "A-Current" # Current sensor name
voltage:
name: "A-Voltage" # Voltage sensor name
energy:
name: "A-Energy" # Energy sensor name
power:
name: "A-Power" # Power sensor name
id: A_POWER
frequency:
name: "A-Frequency" # Frequency sensor name
power_factor:
name: "A-PowerFactor" # Power factor sensor name
update_interval: 9s # Update interval: 9 seconds
- platform: pzemac
id: pzemac_B
address: 0x02
current:
name: "B-Current"
voltage:
name: "B-Voltage"
energy:
name: "B-Energy"
power:
name: "B-Power"
id: B_POWER
frequency:
name: "B-Frequency"
power_factor:
name: "B-PowerFactor"
update_interval: 10s
- platform: pzemac
id: pzemac_C
address: 0x03
current:
name: "C-Current"
voltage:
name: "C-Voltage"
energy:
name: "C-Energy"
power:
name: "C-Power"
id: C_POWER
frequency:
name: "C-Frequency"
power_factor:
name: "C-PowerFactor"
update_interval: 11s
- platform: wifi_signal # Reports WiFi signal strength (RSSI) in dB
name: "WiFi Signal dB"
id: wifi_signal_db
update_interval: 60s
entity_category: "diagnostic"
- platform: copy # Reports WiFi signal strength in %
source_id: wifi_signal_db
name: "WiFi Signal Percent"
filters:
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
unit_of_measurement: "Signal %"
entity_category: "diagnostic"
device_class: ""
status_led:
pin: GPIO8
time:
- platform: sntp
id: current_time
timezone: Asia/Shanghai
servers:
- ntp.aliyun.com
- ntp.tencent.com
- stdtime.gov.hk
on_time:
- seconds: 0
minutes: 0
hours: 0
days_of_month: 1
then:
- pzemac.reset_energy: pzemac_A # Reset energy counter for sensor A on the 1st of each month at midnight
- pzemac.reset_energy: pzemac_B # Reset energy counter for sensor B
- pzemac.reset_energy: pzemac_C # Reset energy counter for sensor C
on_time_sync:
then:
- logger.log: "Synchronized system clock"
Other Recommended Open Source Projects
- STM32F030C8T6 Minimal System Board and LED Sequencer (Schematic & PCB): https://blog.zeruns.com/archives/715.html
- MSP430F149 Minimal System Board Open Source: https://blog.zeruns.com/archives/713.html
- 2007 Electronic Competition Power Supply Topic: 30-36V Adjustable Boost DC-DC Module (UC3843): https://oshwhub.com/zeruns/36v-sheng-ya-dcdc-mo-kuai-uc3842
- STC12C5A60S2 Minimal System Board / 51 Microcontroller Temperature Display and Fan Control: https://blog.zeruns.com/archives/721.html
Recommended Articles
- Affordable and Cost-Effective VPS/Cloud Server Recommendations:https://blog.zeruns.com/archives/383.html
- Minecraft Server Setup Guide: https://blog.zeruns.com/tag/mc/
- My Home Network Cabinet Setup and Recommendations: https://blog.zeruns.com/archives/732.html
- Orange Pi 3B (RK3566) Development Board Review: https://blog.zeruns.com/archives/729.html
Comment Section