Connecting a PeaceFair Pzem-004T to an Espressif ESP8266


I am using this firmware:

Which router interface??

I have 2 PZEM’s. One is to monitor the power from the solar appliance, the other is to monitor the power from the grid provider.


That is the correct file but our firmware doesn’t have any references to MicroPython access points.

Upload a screenshot of the next flash that you do, showing the flash worked OK.

Maybe your WeMos supplier is sending them out with MicroPython flashed on them but that means you are not flashing our firmware correctly.

The router interface is a visual representation (known as a GUI) of the settings for the device.Normally accessed on or something similar with a username and password. Some ISP’s lock down their routers so end users can’t use the GUI.


This is the after flash

When i scan for ssid there is the micropython ssid, also i did a scan in the router and i get the micropython ssid.

Of both WeMos, only 1 has the micropython ssid, the other has no ssid.


I see what the problem is.

As per the link to the screenshot I provided you need to:

  1. Click the box to the left of the path to the bin file.
  2. Add the address of 0x000000 in the box to the right of the path to the bin file.

The bin file should then be highlighted in green and you can flash again.
Copy of screenshot for reference, ignore the name of the bin file in the screenshot as that was just a bespoke bin file for a user to test.


Done! I flashed both Wemos sucessfully! Now i have to connect the wemos to the PZEM. When i receive the dupont cable i will return to more support!

I also tryed to setup the app, but in the final check it says it can’t connect, i believe that its the part i have to buy the token.

Thank you


You don’t need to buy the token for the app to connect to the WeMos. Just keep trying. There is a guide on this site to help with this provisioning stage.
As you don’t have the dupont cables you can still run the app and it will produce simulated data.


The simulated data is running, and it’s awesome!

Can’t wait to have the PZEM running!


Actually I should say that Dupont cables are not really recommended as they are a little too big for the pins on the Pzem and they can slip off. Did you see the cable we recommend as they are a really tight fit on the pins?


The 4 way cable with the plus marks? Where can i get? Ali?


Yes I got mine from Ali. They are a little shorter than I would like and ideally 4 colours would be best rather than the silly plus marks but they are certainly better than Dupont for connecting to the Pzem.


I have been looking a way to phisical connect the espressif to the pzem, but without soldering there is not much choice. This board makes that very easy. Is she available in Ali?? I made some search but no sucess…


I have the PCB’s here but you would still need to solder it. For users that want a board we are currently charging $4 plus postage and packing but you would need to source the components i.e. headers, resistor, PCB connection blocks etc.


@Costas Hello, I have read some of the comments around 37/172 - 42/172 and found that its the same work that i have been working for my project. I wish Mr.Costas will help me out please. I will set up the connection at my house main panel of CT, Pzem 004t and Wemos d1 mini (esp8266) to monitoring the energy consumption. CT will clamp the L-wire at the red circle in the figure, Am i right? Is it the correct wire to hook by CT if i want to measure the energy data?


Then, the thing that i wonder is how can i connect the wires in the blue circle in this following figure to the Pzem-004t

From what i understand,(the other 2 ports of pzem will connect to the wire from CT which is not my problem) those 2 wires in blue circle are from L and N wires will connect to Pzem-004t?. I dont know how to connect those 2 wires to the Pzem. Can u help me please? and sorry for my english, its not my native language. Thank you ! looking forward for your answer :))


I have tried with dupont cable, with both female ends. But no joy.


and the ESP

I have no clue why is not working.


If that is the main live feed into the consumer unit then yes.


You should really be getting an electrician to do this for you if you don’t understand the wiring diagram. The area marked in blue requires live to the top connection and neutral to the one below it.


In the first post of this thread I wrote:

GPIO 12 (D6) is receiving data from the Pzem and connected to the port marked TX in the image above.
GPIO 13 (D7) is sending a request to the Pzem to send data and connected to the port marked RX.

Looking at your photos it doesn’t look like you have it wired up correctly. TX is white and goes to D6 but you have it on D7.


I think it should be live wire. Thank you.


I 've already hired electrician but i only told him about remove the main live so i can hook CT on it. Then, i just saw that there are live and neutral that also have to connect to pzem-004t as your reply. Can you give me an idea about how to make live and neutral from my main panel to be the wires that can connect to Pzem-004t?