AS THIS IS THE MOST IN DEMAND ENTRY. I’M CONSTANTLY UPDATING IT.
IF YOU HAVE ANY QUESTIONS PLEASE ASK.
- 2020.08.09 was browsing AE and saw this Dual Display 40A 63A 230V Din Rail Adjustable digital Over Under Voltage Relay Surge Protector Limit Over Current Protection
- 2020.04.26: all is well with this setup. Just watched “Tech with Shae and his DIY home monitor setup. Good for the people of North America.https://youtu.be/x5r0qquFne8
- 2020.02.20: my first failure occurred. Roughy a month since I updated to a different nodemcu and updated Tasmota to 8.1. The readings have frozen for about 24hours. Logging into Tasmota is not possible, Tasmota seems frozen/unresponsive.
- 2020.01.26: After almost 2 years of continuous flawless operations I’ve decided to update the Tasmota firmware from 5.12 to 8.1. It didn’t go well (post coming soon). But it seems to run without issue. Link
- It seems the pzem-004 v3 has a different configuration in Tasmota to the previous versions https://github.com/arendst/Tasmota/wiki/PZEM004T-Energy-Monitor. Maybe the new settings are enough, maybe like some report it won’t work.
- 2019.09.11 (JST) The HookUp has a ShellyEM video as well https://www.youtube.com/watch?v=5RyDxZLA8b8
- 2109.08.19: Using a Shelly seems easy. https://youtu.be/pdo0IzpEEMI see links in video description too.
- 2019.07.14: hmm must have missed Dr ZZz talking about the PZEM ealier this year https://youtu.be/_djX-7c2kg4?t=3995
- 2019.06.03: This setup has been rock solid for over a year without any changes. 👌
- 2019.04.26: from Sendorm is a cleaner way to power the system without a separate usb power adapter
- 2019.04.16:To simplify the process of the code below I have put it online at https://github.com/halfforked/PowerMeter/tree/master
- 2018.09.09 – Post split in multiple pieces see part 2 as well
ALTERNATIVES* (added 2019.03.02)
- Using a Shelly seems to be an easier way to go. Posted above as well. https://youtu.be/pdo0IzpEEMI
- This is an Energy meter (for a single device?) but the principle is the same. Note the if you try this you’ll NEED a SPLIT COIL instead. https://github.com/arendst/Sonoff-Tasmota/wiki/PZEM004T,-Wemos-D1-Mini-and-a-1602-I2C-display
- SMART METER: if you have a smart meter then things may get much easier for you. https://cloudenius.com/2018/08/04/use-smart-energy-meter-with-home-assistant/
- PRE-BUILT/service – 3 phase: https://efergy.com/engage-online-monitoring/ (unsure about integration in Home Assistant)
- PRE-BUILT/service: https://openenergymonitor.org/ (unsure about integration in Home Assistant)
- There is a suggestion for a 3 phase system on https://community.home-assistant.io/t/whole-house-power-monitoring-single-phase-for-under-30/68793/15
The standard disclaimer: Please do not attempt anything seen here if you’re not comfortable with breakers and mains power.
At this point I had BRUH room sensors in every room (except bathroom) and outside.
The next step was to have whole house monitoring. Which was finally done this morning.
A couple weeks back I received my PZEM-004. Without a clue on how to hook it up to hassio. I figured there had to be a way.
I was ready to reflash a nodemcu with original programming if I had to. I wanted house wide power monitoring but couldn’t get many ready made products in Japan nor wanted to pay 200-500USD for them. For example this awesome looking SENSE unit reviewed a while back by BRUH.
Sure I won’t have the detection software that will figure out the various appliances for me, which would be very nice, but realistically at sub 30$ I’m quite happy.
The PZEM-004 with display, split coil current transformer (CT) with a usb wire for power set me back a tiny 2116JPY (20USD) [nodemcu was 3USD]
This unit has a limit of 100Amps, but as this leaning house has a average-small 30Amp breaker box, this would be ample.
This is what I bought. PZEM-004 link here. I commented that it does make a buzzing noise when powered, if it’s an issue in tiny-house-Japan. Of course if you want an even cheaper one, get it without the display. (Although I don’t recommend it as with display it’s easier to test)
- Using a cable with a plug on one end and bare cable on the other (i.e. like a cut extension cord). I used a cable bare on both ends and temporarily attached a plug to one end.
- Connect the bare cable ends into the PZEM-004 as per the instructions on the unit
- Connect the coil (if not already attached) and put ONE of the two wires in the extension cable through it again as per the instructions on the unit. (not both wires as the currents will cancel each other out)
- Power the PZEM004 via the included USB cable. I opted to use a double USB charger with one side powering the NodeMCU and the other powering the PZEM004 plugged into a power strip with a switch. (I’m guessing you could *maybe* power the PZEM004 from the VIN pin of the NodeMCU as this is the same as connecting to the USB plug directly)
UPDATE 2019.04.26 from Sendorm
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.
- USING a power strip with a switch at OFF, plug in the “plug” end of the cut extension cable.
- Clearing away any other debris, things around, turn on the power strip.
- You should be getting a reading on the PZEM004 (if you have a screen)
Providing power to the PZEM004 to TEST it worked without a hitch with a cable to the mains. I used a cable with a plug on the end and bare wires on the other. The bare wires powered the PZEM004 and splitting cable into the two wires carefully preserving the rubber the coil was attached to ONE of the wires. After the setup I plugged the cable into the wall and power readouts appeared on screen. TEST successful.
How to get it to play nicely with TASMOTA? (then Home Assistant)
- [update 2019.09.11] I use the nodeflasher, it’s old but just works well for me, and flash TASMOTA v6.6.0 onto a nodeMCU. There is no fussing around with Arduino or anything anymore
TASMOTA v6.6.0 this sonoff.bin (standard)
- [original] Flash tasmota on the NodeMCU or Wemos. The Sonoff basic doesn’t have the pins necessary to connect with. (I flashed with the ARUDINO IDE as I wanted to select the WIFI AP mode and Enter a name for this NodeMCU as “powermeter“)
**If using the Arduino IDE be sure not to use ESP8266 version 2.4.X I would downgrade to 2.3.0 for now (2018.09.09) link
- Make sure the PZEM-004 is disconnected or the switch is off. Using the picture on the back of the unit connect the PZEM RX -> NODEMCU TX and the PZEM TX-> NODEMCU RX pins.
That pretty much takes care of the physical connection.
- Connect to the tasmota firmware at the IP address on your network
- Set to generic
- Set the pins you chose (in my case see below)
- Enter the MQTT server info
And that should be it for Tasmota-NodeMCU (Wemos).
When switching on the power again, the PZEM and the USB powered NodeMCU should be working together and logging into the NodeMCU you should see the following. (WITHOUT THE TEMPERATURE INFO)
Next, how to extract the Tasmota’s PZEM004T information. Without any more steps the MQTT is receiving the following data.
To find this out I got lucky as this NodeMCU was a former BRUH Multisensor. Checking the logs and was able to find the JSON code to extract this information. I tested many ways to get the information from the PZEM MQTT messages. In the end after I got my results I stumbled on this page. https://github.com/arendst/Sonoff-Tasmota/issues/1595
UPDATE 2019.04.16: To simplify the process of the code below I have put it online at https://github.com/halfforked/PowerMeter/tree/master
By entering the above as MQTT entities the data will be properly extracted to Home Assistant.
One problem I encountered was the slow update time of the information. The humidity and temperatures were updating by the second whereas the power updates were every 300 seconds.
- OPTION 1 – On TASMOTA firmware v6.6.0 go to MENU – CONFIGURATION – CONFIGURE LOGGING – Telemetry Period and change the value to 10
- OPTION 2 – Changing the following TELEPERIOD setting is the original way. See below
Changing that to 10 seconds made everything so much better and usable. By entering “Teleperiod 10” to update every 10 seconds.
UPDATE 2019.05.05: If “Teleperiod 10” for 10 second interval updates is still too slow for your liking there is the possibility to update the Tasmota code as commenter SeByDocKy
Finally, I recompiled the last tasmota firmware and made the two following changes in the sonoff.ino (around line 1204)if ((payload >= 0) && (payload 0) && (Settings.tele_period < 10)) Settings.tele_period = 10; // Do not allow periods < 10 secondsWorks fine for Teleperiod 1
SeByDocKy‘s link: see the comments (I didn’t have time to test it myself, see comments for any issues that may arise)
This is an interesting workaround. However having said that I will be leaving the tasmota code untouched for the time being as 10 seconds doesn’t bother me so much. Plus I’m curious as to why there would be a 10 second minimum in tasmota in the first place. Long term usage to be the final test perhaps.
Congrats the safe part is done.
Just FYI this seems to be a good link to check for bugs with the PZEM. https://github.com/olehs/PZEM004T/issues