Connecting a PeaceFair Pzem-004T to an Espressif ESP8266


#142

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.


#143

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
#144

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 ?


#145

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.


#146

Ok perfect !


#147

Sending LIVE data now ! :slight_smile:


#148

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


#149

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)


#150

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?


#151

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,

Tony


#152

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.


#153

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


#154

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.
Peacefair%20Pzem%20004T%20with%20split%20core%20current%20transformer%20CT

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.


#155

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


#156

You can use any flashing tool you are comfortable with.


#157

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?


#158

No, set the SPI mode to DIO as per the screenshot I linked to.
You will see the progress of the flash and it’s pretty clear when it’s been done.
After the flash the WeMos should appear on your WiFi network as an access point called “ESPproMon”.

I will get back to you regarding the connections and the cable etc.

PCB means printed circuit board, basically the green board shown in the first image of the thread. We sell them but the system can be built without one and we recommend thorough breadboard testing before going live in an electrical consumer unit.


#159

The USB cable you have is to use some fairly basic software that Pzem provides for PC use.
I was going to say you could hack the cable but its best to keep it as it is.
You need to solder the 8 pin headers on each side of the WeMos.
Do you have 4 dupont cables, preferably male one end to go into a breadboard and female to connect to the Pzem at the other. I’m assuming you have a breadboard.

Have you seen the required connections from the start of this thread?

I believe you wrote in the other thread that you have 2 WeMos i.e. one as a backup. We are 99% sure that as long as you wire it up correctly that 5V to 3.3V is not an issue. As you have a backup I would wire the cables directly without a voltage divider. If you only had 1 WeMos and it would take up to 6 weeks to get another from the Far East we would say add the voltage divider.


#160

I did the flashing and the only SSID i get is MicroPython-1d8884.

I will buy from ali a breadboard and dupont cables, and then i get back.

Both wemos are for 2 solar appliances i have!!

Thank you


#161

That’s not from our firmware.
Try the flash again and what do you see in the router interface for the WeMos?

Did you buy 2 Pzem’s?