So far I made 10 of these. I'm using a generic bar soap case as an enclosure. Soap cases are less than 1 USD.
I'm using a cheap bidirectional 5V-3V digital converter module to power the ESP01 with 5V and also to allow bidirectional communication with 5V serial TTL with PZEM. Also I'm using a simple USB TTL converter for ESP01 for programming. I've added a switch to put it into programming mode and a button to reset.
Power supplies are 5V USB chargers. I bought 25 of them from Amazon at 1 USD each when they were on sale. They are about 5 USD each now which is still a bit cheaper than their regular price.
I'm using computer power cables with IEC connectors. I cut the IEC connector and add a female mains connector. I using cable ties to keep the power cables from moving.
The way I wired the PZEM module allows me to measure its own consumption as well as the 5V power supply in addition to the load.
Here is the ESPHome code.
substitutions:
device_description: "Fridge"
esphome:
name: powermeter-10
comment: '${device_description}'
esp8266:
board: esp01_1m
# Enable logging
logger:
baud_rate: 0
# Enable Home Assistant API
api:
ota:
password: "*****"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Powermeter-10 Fallback Hotspot"
password: "*****"
captive_portal:
uart:
tx_pin: GPIO1
rx_pin: GPIO3
baud_rate: 9600
modbus:
sensor:
- platform: pzemac
current:
name: "PM-${device_description} Current"
voltage:
name: "PM-${device_description} Voltage"
power:
name: "PM-${device_description} Power"
energy:
name: "PM-${device_description} Energy"
frequency:
name: "PM-${device_description} Frequency"
power_factor:
name: "PM-${device_description} Power Factor"
update_interval: 2s