Whole house power monitoring (single phase) for under 30$

Hello, I’ve just finished the project as the guide from @Leaninghouse

One thing to add, I am powering the pzem-004t TTL from the nodemcu VU pin and it is working perfectly. It seems a separate usb power adapter is not necessary after all.

Also I am creating mqqt discovery config messages from MQTT.Fx for auto-discovery.
For instance:

For Voltage:

Topic: homeassistant/sensor/home_voltage/config
Message: {"name": "Home Voltage", "state_topic": "tele/sonoff/SENSOR", "unit_of_measurement": "V", "value_template": "{{ value_json['ENERGY'].Voltage  }}"  }

For Watt:

Topic: homeassistant/sensor/ev_watt/config
message: {"name": "Home Watt", "state_topic": "tele/sonoff/SENSOR", "unit_of_measurement": "W", "value_template": "{{ value_json['ENERGY'].Power  }}"  }

The message the nodemcu sends has following values, one can create required sensors as previously mentioned.

tele/sonoff/SENSOR = {"Time":"2019-03-25T18:15:09","ENERGY":{"TotalStartTime":"2019-03-25T00:26:03","Total":0.011,"Yesterday":0.000,"Today":0.011,"Period":1,"Power":80,"ApparentPower":120,"ReactivePower":90,"Factor":0.67,"Voltage":227,"Current":0.530}}

1 Like

Awesome.
Good to know the nodemcu can power the setup! It can make things simpler.

I’d like to know long term if you have any issues.
Thus far it’s been rock solid without issues for about a year now.

I hope you don’t mind I’ve added your addition to the guide.

I will inform if any problem arises. Also I wouldn’t mind and will actually be glad if you include the addition :slight_smile: Thank you for the great guide.

1 Like

Hello, thank you for this guide. I have followed it as best I can however I am stuck. I have flashed my nodemcu and wired everything correctly however no values appear on my tasmota webpage. I am using a newer version of tasmota than the one in the guide 6.5.0.4 one difference is when setting the GPIO pins I use PZEM0XX TX (62) and PZEN004 Rx (63), however no such luck. I have tried with a wemos d1 and nodemcu now. If anyone has any suggestions I would really appreciate

1 Like

Try with sonoff-sensors.bin

1 Like

Hmm I am unfamiliar with this as I haven’t touched my setup in a year.
However I did come across this
https://github.com/arendst/Sonoff-Tasmota/issues/4472

There are mentions that if the pins are reversed it may not work.

Would you be able to provide more detail about your setup?

Hi,
I was reading this post about using the USR-W610 with the PZEM-016 and I was wondering if anyone can assist me with getting mine set up. currently I have everything connect with the Pzem-016 connected to live and neutral and the ct connected…On the rs485 side, I have a twisted pair cable going from the A and B port of the PZem to the A and B of the USR. but nothing is happening, the TXD and RXD leds are not blinking (not sure if they should be but that makes sense to me). I was also wondering which settings should be used to the USR-w610 and if something there is causing this not to work or if i have a fault device. I have ordered a usb to RS485 to test the PZEMs (i bought 2) but I don’t think it’s them…Can anyone provide any insight ?

P.S. I PM’d Silicon_Avatar yesterday evening but no reply as yet.

I’m doing the same thing, 3 fase using them following and an ESP32 with Esphome. Works like a charm.

https://m.aliexpress.com/item/32527933292.html?spm=a2g0n.orderlist-amp.item.32527933292&aff_trace_key=9687e0275eb7455698fc80a07e6e3a1f-1554804947869-06356-cEB05Kda&aff_platform=msite&m_page_id=7038amp-l8TzuRJ2s3zkgQgM3PaljQ1555661102355

1 Like

Luke is it running?

As I was updating tasmota on a device I noted that not all firmware are the same.
Some firmaware versions do not have the PZEM004T sensor capabilities.

This is what blakadder said. Which went under my radar.

Sorry. I managed to get it working by assigning GPIO D1 and D2 instead of the nodemcu’s TX RX pins. I also was able to use my power companies kwh rate and use a calculation to show daily cost on my home screen. I also have this logged onto a google spreadsheet daily to keep track

1 Like

Hello can you share the code for logging to google spreadsheet? Thank you.

1 Like

Please share HA config. I am trying to read PZEM-016 straight via Modbus RTU, but I am getting some strange numbers … Thanks a lot. Peter

My whole config is on github, this is the modbus sensors section:

https://github.com/SiliconAvatar/HAConfig/blob/f385f0bcf751daf1dfb5abae0920ca0309f25f36/Sensors/Modbus.yaml

1 Like

Hi, I’m looking to do the same! How do you connect the SDM72D to ESP32?

I’m not seeing that SDM72D comes with a TX or RX port anywhere.

It has a pulse output. You just count the pulses with ESPHome.

1 Like

Guys, how do you reset the energy acumulator. I want to have a monthly energy consumption and I want to reset the energy acumulator every month.
I am using PZEM-016 and a serial Port RS485 to WiFi device (Elfin-EW11).
I have this config:

modbus:
  name: pzem016
  type: tcp
  host: 192.168.0.105
  port: 8899

sensor:
- platform: modbus
  scan_interval: 5
  registers:
  - name: pzem016_voltage
    hub: pzem016
    unit_of_measurement: V
    slave: 1
    register: 0
    register_type: input
    scale: 0.1
    offset: 0
    precision: 1
  - name: pzem016_current
    hub: pzem016
    unit_of_measurement: A
    slave: 1
    register: 1
    count: 2
    reverse_order: true
    register_type: input
    scale: 0.001
    offset: 0
    precision: 1
  - name: pzem016_power
    hub: pzem016
    unit_of_measurement: W
    slave: 1
    register: 3
    count: 2
    reverse_order: true
    register_type: input
    scale: 0.1
    offset: 0
    precision: 1
  - name: pzem016_wh
    hub: pzem016
    unit_of_measurement: Wh
    slave: 1
    register: 5
    count: 2
    reverse_order: true
    register_type: input
    scale: 1
    offset: 0
    precision: 1
  - name: pzem016_frequency
    hub: pzem016
    unit_of_measurement: Hz
    slave: 1
    register: 7
    register_type: input
    scale: 0.1
    offset: 0
    precision: 1
  - name: pzem016_powerFactor
    hub: pzem016
    unit_of_measurement: Pf
    slave: 1
    register: 8
    register_type: input
    scale: 0.01
    offset: 0
    precision: 1

I found some data here:
http://lechacal.com/wiki/index.php/Use_PZEM-016_with_MODWRT#Reset_Energy
The cli command for a RS485 device would have been:

modbus_raw_send 9600-8-N-1 01 42

I tried to adapt that for the service modbus.write_register, and I thought that I should have a yaml data like this:

hub: pzem016
unit: 1
address: 5
value: 42

But is not working.
Any ideas?

I’m just switching my very reliable pzem004t v2 with a node MCU powered by espurna over. Problem was that the maximum reliable update frequency for the sensor is 6 seconds. The problem relies somewhat in a limit of polls for this sensor in revision v1 and v2.

So now I grabbed the neweset pzem004t v3 ($7) and wired it up to a esphomatized esp m3 ($1.5) together with these basic ams1117 5v to 3.3v board ($0.20).

For $8.70 I now have a mqtt free real time (this time for real, updates of the values coming in more than once in a second) view of my whole energy consumption. The sensor also exposes more values now like power factor and frequency.

The component is not yet in the stable release so best is to grab this one here for now: https://github.com/esphome/feature-requests/issues/49#issuecomment-538636809

It should also be possible (in theory) to hook more than one pzem004t’s to one esp to measure for example a three phase system.

Hi All,

I’m just wondering if anyone tried using a single PZEM-004T for monitoring a 3-phase system?

My theory is to clamp it on the neutral wire - which in my case collects load from all 3 phases, and there is no 3-phase load…

I would guess the 42 is in HEX and your yaml value is then DEC?

I’ve only had a PZEM-016 for a couple of days but noticed over the course of a day the utility meter reads a couple of extra kw/h used than the PZEM-016. Is this because my power factor is generally 0.8?