Connecting a PeaceFair Pzem-004T to an Espressif ESP8266


Should I start provisioning again ?


Yes I can see that the Gmail account has a live project on the server.

Go through provisioning.

Think the problem all along was that you was flashing as 512 MB device not a 4MB device. The flash size in Mbit is 8 times the RAM size. I am doing some screenshots.


Okay … Up and running in demo again, naked Wemos …


Will let it run for an hour and keep you posted !


You can plug it into the PCB now and you didn’t need the bin file without the hardware EEPROM reset removed.
You were trying to store the EEPROM data in an invalid location by flashing the WeMos as a 1M rather than then correct 4M device.
All we need to do is make sure you have the pot / voltage divider set up correctly.


I am posting the details of the Espressif Download Tool here to ensure users flash their 4M (WeMos / NodeMCU) devices as 32Mbit and not 4Mbit. I will also post a link at the start of this thread.

The download tool is available on Espressif’s site.

Provisioning your ESP8266 with our server
Source for WeMos D1 Mini

I remember during one of the discussuions, probably with Paul, that we excluded the flashing as an issue as the ESP seemed to work at first. But indeed this can be very well the issue ! I will plug it in the PCB later on this evening. As for the voltage divider, I have no 3K or similar potmeter in stock. So I will use the 1K/2K divider as youn suggested somewhere earlier ? Anyway BIG THANKS for your continued efforts !!!

I suggest to proceed as follows :

  1. Flash again with the “standard” firmware latest version
  2. Mount on PCB
  3. Connect PZEM using 1K/2K voltage divider
  4. Continue to use the Gmail login for now

OK ?


I would stick with the firmware you have. As you have the same version number it will automatically update to the latest version when we do the next update.

Yes use the Gmail account.


Ok perfect !


Sending LIVE data now ! :slight_smile:


@Tony looks like your system has made it safely through the night without clearing the EEPROM.


Absolutely !!! :smile: ! Just one remark … The voltage divider 1K/2K did not work for me so I currently have the PZEM connected directly to D6/D7 of the Wemos !

Next step : get the data to a portal (Thingspeak, EmonCMS … ?) and then build the final version in a nice looking box. Fibnal goal … get a dashboard with my consumption versus energy injection from my solar panels. Ideally, include every major energy absorbing device monitored individually. (Doing this already using Fifthplay but doesn’t integrate with anything unfortunately)


For many users it’s not a problem to connect the Pzem directly to the WeMos but it’s an extra precaution that we recommend. The ESP8266 community is divided, no pun intended, as to whether it’s safe to feed WeMos data pins with 5V. As you know it’s actually about 4.6 to 4.8V that is feeding the Pzem from the WeMos and I believe the return to the RX pin on the WeMos is possibly less than the actual input to the Pzem.

Globally many users, me included, have accidentally or intentionally made a direct connection and not observed any visible problems after many months of use. The benefit of a direct connection is that is a simple plug and play so you don’t have to adjust a pot or the resistors to get the ideal return voltage to the WeMos.

If a user only has 1 WeMos, has a lead time of 6 weeks for a replacement WeMos and is planning to bury the WeMos deep inside a consumer unit we would recommend a voltage divider.

If your WeMos is going to be fairly accessible and you have a spare then it’s probably fine to risk running it without the voltage divider.

Now Thingspeak, EmonCMS and Fifthplay - don’t enter any API keys via the app or you are almost certain to have problems. Things need to be set up in a very specific way with these 3rd party networks for the ESPproMon to accept the API key. If you do it wrong our servers and the 3rd party networks at best restrict your access and at worse close down your account.

I have provided some of the basic details of how to set up Thingspeak or EmonCMS but I still need to add further instructions. Thingspeak is easiest but EmonCMS is my personal preference.

I am not familiar with Fifthplay but I can check them out. Do you have a link to their API etc?

I know you are fairly familiar with Thingspeak but we need to go through the exact process before you enter any API keys in the app.

Assuming we can integrate Fifthplay into our app which would be your preference to use with our app between the 3 different networks?


Hello Costas,

As for the voltage divider, I will look into an alternative by putting a level shifter or similar between the two. But will also keep a spare Wemos D1 flashed on hand.

I tried to set up EmonCms (entered the API key and the node number) but get no results in their portal yet. As you advise against it, I will clear the key for now. Fifthplay AFAIK has no API available nor do they integrate with IFTTT or anaything else basically. So I will probably abandon them and get some plugs that measure energy consumption. Ideally again, I would like to integrate all in one single home automation portal. I am using Smartthings for home automation and Actiontiles as an interface for most stuff. Having energy consumption and solar panel production nicely in some dashboard would be great. I believe that solutions like yours will gain a lot more attention but there’s a huge lack of integration of all that stuff. Currently I have Smartthings, Philips Hue, Tado Smart thermostat, Solar Panel solution with API that I still need to examine, the Fiftplay plugs, IP cameras and lots of ESP based devices measuring and switching stuff.

The work you did in Blynk is amazing, big kudos for that !!! There’s still some stuff in there that I’m not sure of how to read/use but I’ll get around that soon enough. As for integration of all these devices and functionality, one central “hub” such as Actiontiles would be ideal since it represents visually all information about your home and it’s devices and let’s you inteact with them through a simple tablet with a browser that you can install somewhere permanently in the house as your control panel.

Kind Regards,



As you are aware Blynk has some excellent tools that we used to build the smartphone app and hopefully we can help with some of the integration.

The app is already way too complex for Joe Public and even the relatively simple task of flashing the initial firmware is not fool proof, as you have proved :slight_smile: So we have to be careful to try and only add generic features to the app that will have broad appeal to many users.

I love the Peacefair Pzem, WeMos, 3rd party networks, Blynk and the way it’s all tied up in the ESPproMon app. Obviously as the app developer it’s a little easier for me to do the integration and make full use of the temperature sensor, RF transmitter, surveillance cameras and geo-location control etc as I wrote the firmware.

I do hope so as it’s taken quite a bit of effort to get to the stage we are at and there are lots of further work we could do if the industry shows some support for our app. Hopefully you can help us by providing reviews and ratings of the app on iTunes and the Google Play store etc.

ESPproMon already has a lot of this covered. The firmware already has basic code to bridge to additional ESP’s but again there is some much more we can do. The QR code you scan is just one of 5 different versions of the app that users can switch between and a quick firmware update can turn it into a totally different project.

Thanks for your comments.

I will get back to you shortly about EmonCMS integration.


I think we will take the discussion regarding EmonCMS integration to the dedicated thread at ESPproMon Integration


Just to clarify it’s only the Peacefair Pzem 004 and 004T that have a TTL port so you can’t easily hook up any of the other Peacefair models to an ESP8266.

We always recommend the split core current transformer (CT) and we feel it’s worth paying a few dollars more for the LED display.

The photo above is what you need to order or alternatively the same unit but without the LED display and case.

When we buy these units we purchase them direct from the manufacturer on AliExpress.
This is the link for their listing.


Regarding the flash of bin file, can i flash it using the ESP8266 Download Tool, or i can only flash using the ??


You can use any flashing tool you are comfortable with.


I have this:

Is it safe to Start? And how do i know that the flash was well done?

Mean while, i was looking at the connections between the WeMos and the PZ.

I have no ideia where which is the VDD, Rx, Tx and GND…
And i have to buy and usb to micro usb adaptor. The PZ cable is only USB :stuck_out_tongue:

Also, i read about the 5V and 3,3V. Do you advise to change the voltage to 3,3V ?? Whats a PCB?