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

Nice post, and good job!

For those thinking about doing something similar, I’m also doing whole house monitoring.

I’m using the PZEM-016, which has no display but seems otherwise very similar. Since I have a split phase system and I wanted to monitor both legs, I didn’t want to have two ESPs flashed with tasmota running next to each other, so I’m using the USR-W610 to connect to the two modbus outputs of the PZEMs and convert them to modbus TCP/IP and connect it to my WiFi. From there I use the Home-Assistant Modbus TCP component to read the values, and some template sensors to combine them.

1 Like

very interested in doing the same - did you document how you did it? by monitoring both legs do you mean you can monitor two mains power inputs?

1 Like

Guys anyone can direct me to how to monitor two different main lines i.e backup generators vs mains - mainly i need to know my house is drawing power from which line: line 1 or line 2 - thanks

1 Like

One way to accomplish this without getting the power draw is to connect a sonoff to each source and monitor the online/offline status. (ex. If sonoff1 is on main power is on, if sonoff 2 is on then the backup is on)

1 Like

Sure,

I just got two PZEM-016s, with the split core current transformer, and put one CT on each of the two legs of my incoming power. Photo to show it a bit better.

From there, I used a computer with a RS485 to USB converter to change the modbus address of one of them. This is because modbus is a multi-node communication protocol that allows for many devices on the same 2 wire bus, but all nodes must have a unique address for that to work, and all the PZEMs ship with the same address. The manual for them explains how to set this.

With both modules having a different slave address, I used a USR-W610 ($35 on ebay) to convert the serial modbus RTU to modbus TCP/IP (the USR-W610 has built-in wifi as well as a RJ45 port). Then just added the modbus component in home-assistant to pull in the data.

It sounds more complicated than it is honestly. I can share my HA config for it if you want, but it’s pretty basic.

2 Likes

Sorry I know it’s way past the useful time to respond.
It should. Be careful to get a split coil.

1 Like

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.