# Pzem-004t via EspEasy

**URL:** https://discourse.nodered.org/t/pzem-004t-via-espeasy/82580
**Category:** Hardware
**Created:** [3 November 2023 13:37 UTC](https://discourse.nodered.org/t/pzem-004t-via-espeasy/82580 "2023-11-03T13:37:43Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)
#### Post date: [3 November 2023 13:37 UTC](https://discourse.nodered.org/t/pzem-004t-via-espeasy/82580/1 "2023-11-03T13:37:43Z")

</div>

Continuing the discussion from [3-phase power consumption measurement](https://discourse.nodered.org/t/3-phase-power-consumption-measurement/68489/66):

> [@3-phase power consumption measurement](https://discourse.nodered.org/t/3-phase-power-consumption-measurement/68489/66):
>
> Hi I just added 6 PZEM-004Tv3 onto 1 WT32 ETH01 running with ESP\_Easy\_mega\_20221105\_energy\_ESP32\_4M316k\_ETH. I am measure all data and send to my mqtt. Further processing per nodered

Hi @edstobi,  
I would appreciate if you could share a bit more details about your settings, wiring diagram, ...  
Because I have now added 1 pzem-004t module to my wt32-eth01 but I get no values. Although I have used the same settings as you:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/f/3f6645af1cdbf70ec2286b2596f47a9a96394ed6.png)

Thanks a lot!!  
Bart

---

<div class="post-metadata">

### Author: ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)
#### Post date: [14 November 2023 22:22 UTC](https://discourse.nodered.org/t/pzem-004t-via-espeasy/82580/2 "2023-11-14T22:22:45Z")

</div>

@edstobi,  
After a lot of trial and error, I learned a lot about pzem-004t but I still get NaN values.  
If you are still around here on Discourse, I hope you can give me some advice...

---

<div class="post-metadata">

### Author: ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)
#### Post date: [14 November 2023 23:10 UTC](https://discourse.nodered.org/t/pzem-004t-via-espeasy/82580/3 "2023-11-14T23:10:01Z")

</div>

I don't use EspEasy, but may be able to help as I have a number of these wired to Tasmota.

Best to check the basic stuff first with only 1 device connected.

Do you see the TX RX LEDs light up at all ?  
Can you share how you wired it up ?

---

<div class="post-metadata">

### Author: ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)
#### Post date: [15 November 2023 07:15 UTC](https://discourse.nodered.org/t/pzem-004t-via-espeasy/82580/4 "2023-11-15T07:15:08Z")

</div>

I have a PZEM-004T connected to a Wemos D1 Mini (ESP8266) flashed with Tasmota that reports readings via MQTT to Node-RED. Here's a link to a thread about interfacing the device.

> [@Need to write one function that will return 3 values](https://discourse.nodered.org/t/need-to-write-one-function-that-will-return-3-values/30931/12):
>
> This is the module I used PZEM-04 0-100A from BangGood with a serial connection to Wemos. I cut the USB connector off the end of the lead and fed the Tx and Rx signals through level shifters as the PZEM-04 used 5V logic and the Wemos is 3v3. It took quite a lot of trail-and-error to find the best pins to use on the Wemos with Tasmota. I can draw out the circuit/schematic over the weekend if you need it.

Couple of things to note are the need for level shifters and make sure Tx & Rx are connected correctly.  
i.e. Tx connects to Rx, and Rx to Tx

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [15 November 2023 09:18 UTC](https://discourse.nodered.org/t/pzem-004t-via-espeasy/82580/5 "2023-11-15T09:18:56Z")

</div>

I use a Pi Zero to talk to the PZEM. The Pi doesn't need level converters. I run node red on it and communicate using the contrib-modbus nodes.

---

<div class="post-metadata">

### Author: ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)
#### Post date: [15 November 2023 11:15 UTC](https://discourse.nodered.org/t/pzem-004t-via-espeasy/82580/6 "2023-11-15T11:15:37Z")

</div>

Hi guys  
Thanks for joining!  
I am also discussing this in the EsPEasy [forum](https://www.letscontrolit.com/forum/viewtopic.php?t=9903).

I have currently only one pzem-004t attached for my test.  
Thanks to the help on the EspEasy [forum](https://www.letscontrolit.com/forum/viewtopic.php?t=9903), I managed to have currently this state:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/d/fdd4db2a2d458d42298b78d0ed12b5576c922295.png)

So I have set the data acquisition interval for this device on EspEasy to 10 seconds. So every 10 seconds the RX LED on my pzem-004t is flashing, and immediately afterwards my TX LED is flashing. So I assume the pzem-004T knows correctly that he is device with address 1 and that he responds with the measurement data.

But EspEasy says the values are Nan...

---

<div class="post-metadata">

### Author: ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)
#### Post date: [15 November 2023 11:20 UTC](https://discourse.nodered.org/t/pzem-004t-via-espeasy/82580/7 "2023-11-15T11:20:52Z")

</div>

What I also not really understand: the receive LED (D3) on my pzem-004t is always on, and flashes intens when it receives a command. On the other hand the transmit LED (D2) is always off, and only flashes when it transmits the results. Not sure if that is normal behaviour of the D3 LED?

---

<div class="post-metadata">

### Author: ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)
#### Post date: [15 November 2023 17:36 UTC](https://discourse.nodered.org/t/pzem-004t-via-espeasy/82580/8 "2023-11-15T17:36:53Z")

</div>

OK that's quite a long thread to read 😉

1: The circuit drawing IS correct, and I have it working here on my desk to prove it 😀

_"Not sure what they are trying to make you do there, as those diodes (what voltage let they pass through?) effectively block any signal to flow to the ESP. "_

This is not true as the signal in question is flowing TO the PZEM via the diode, since the PZEM pulls the line LOW.

2: Are you still using GPIO 15 as this seems to have a pull up resistor which will have an effect on signal levels, so pick another one!

3: You will need to set the addresses on the PZEMs, I think they are all set to 1 by default.  
NOTE, you can only have 1 PZEM connected at a time when setting an address, and there is no feedback, so best to make sure everything is working before trying to set the addresses.

4: The PZEM must be connected to MAINS or it will not work at all, as this powers the internal circuitry, the voltage from the EPS is only to drive the leds.

5: As a quick test you could try wiring the PZEM without any resistors diodes etc, but connect to 3.3V on ESP.

6: Based on your drawing there is 5V on the PZEM RX pin, then the other side of the diode 3.3V, since this is lower, some current can flow through the diode towards the ESP and light the LED all the time.

7: Use Tasmota 🤣 🤣 🤣 🤣

8: Trust your NODE-RED Friends 😉

---

<div class="post-metadata">

### Author: ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)
#### Post date: [15 November 2023 20:13 UTC](https://discourse.nodered.org/t/pzem-004t-via-espeasy/82580/9 "2023-11-15T20:13:47Z")

</div>

> [@Sean-McG](#):
>
> OK that's quite a long thread to read 😉

Ah I had added it just for completeness. But thanks for the effort!!

> [@Sean-McG](#):
>
> The circuit drawing IS correct, and I have it working here on my desk to prove it

Oh, could you please double check if your setup is the same as my diagram above?  
I had drawn that diagram quickly during my short lunch break today, to get some feedback.  
But in my hurry it seems I have drawn it incorrectly ☺  
My setup looks currently like this:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/2/32a90df9bece6e04398ab3d5e2917a417086bfc6.png)

So I would REALLY appreciate if you could double check my drawing with your setup.

I have done it like that, because in our other [discussion](https://discourse.nodered.org/t/3-phase-power-consumption-measurement/68489/163) on Discourse it was adviced to do it that way. Although now I see that in that drawing the pull-up resistor was connected to 5V while mine is connected to 3V3. Perhaps that is my issue?

---

<div class="post-metadata">

### Author: ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)
#### Post date: [15 November 2023 20:24 UTC](https://discourse.nodered.org/t/pzem-004t-via-espeasy/82580/10 "2023-11-15T20:24:34Z")

</div>

Ok I am messing up things completely 🙄

A little bit [further](https://discourse.nodered.org/t/3-phase-power-consumption-measurement/68489/166) in that same Discourse discussion it was agreed that the diodes were in the wrong direction. But afterwards on the EspEasy I was adviced that I needed to turn them again. So now they are positioned like in my last drawing.

Summarized: I don't know whether my resistor needs to be attached to 3.3V or 5V. And I don't know if my diode is in the correct direction. And I also whether I could have damaged my gpio pins due to all my tampering...

---

<div class="post-metadata">

### Author: ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)
#### Post date: [15 November 2023 20:25 UTC](https://discourse.nodered.org/t/pzem-004t-via-espeasy/82580/11 "2023-11-15T20:25:25Z")

</div>

> [@Sean-McG](#):
>
> Trust your NODE-RED Friends 😉

Absolutely 😋

---

<div class="post-metadata">

### Author: ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)
#### Post date: [15 November 2023 22:35 UTC](https://discourse.nodered.org/t/pzem-004t-via-espeasy/82580/12 "2023-11-15T22:35:15Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/9/198ed65558c65871d8e790a69f42a8c1663b09b8.png)  
This is the drawing that represents how I have it wired up on my desk right now.

If check my other points and it still doesn't work, I would suggest testing with another none network ESP with Tasmota.

To test I have had a single PZEM working, wired up using 3.3V instead of 5V without diodes / resistors or converters etc needed.

---

<div class="post-metadata">

### Author: ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)
#### Post date: [15 November 2023 22:49 UTC](https://discourse.nodered.org/t/pzem-004t-via-espeasy/82580/13 "2023-11-15T22:49:55Z")

</div>

Ok thanks a lot!!!  
Will test it tomorrow evening. My time is up for today...

---

<div class="post-metadata">

### Author: ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)
#### Post date: [15 November 2023 22:54 UTC](https://discourse.nodered.org/t/pzem-004t-via-espeasy/82580/14 "2023-11-15T22:54:07Z")

</div>

> [@BartButenaers](#):
>
> Although now I see that in that drawing the pull-up resistor was connected to 5V while mine is connected to 3V3

No 3.3V is correct for the pull up, 5V might damage the ESP .

---

<div class="post-metadata">

### Author: ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)
#### Post date: [16 November 2023 16:18 UTC](https://discourse.nodered.org/t/pzem-004t-via-espeasy/82580/15 "2023-11-16T16:18:49Z")

</div>

> [@Sean-McG](#):
>
> This is the drawing that represents how I have it wired up on my desk right now

Ok quick test between daily job an dinner. Couldn't wait longer 😋

I reversed the diode, and now I finally have at least some measurement:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/5/c5f634c679017a5aec15942a38662921c120be51.png)

How stupid was that...  
You are my hero for today 🤩  
I will never doubt again about the advice I get from my Node-RED friends 🤥

Now I need to figure out why there is no current measured.  
But first a walk in the dark and dinner...

---

<div class="post-metadata">

### Author: ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)
#### Post date: [16 November 2023 16:26 UTC](https://discourse.nodered.org/t/pzem-004t-via-espeasy/82580/16 "2023-11-16T16:26:30Z")

</div>

Do you have a live wire running through the centre of the coil, with some measurable amount of current flowing ?

---

<div class="post-metadata">

### Author: ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)
#### Post date: [16 November 2023 16:27 UTC](https://discourse.nodered.org/t/pzem-004t-via-espeasy/82580/17 "2023-11-16T16:27:51Z")

</div>

Aaaah, a cable consistint out of both neutral and phase. Which probably eliminate each others reading I assume. I will create a setup tonight so I can measure only the phase...

---

<div class="post-metadata">

### Author: ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)
#### Post date: [16 November 2023 16:28 UTC](https://discourse.nodered.org/t/pzem-004t-via-espeasy/82580/18 "2023-11-16T16:28:45Z")

</div>

Correct - Only 1 wire through the coil

---

<div class="post-metadata">

### Author: ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)
#### Post date: [16 November 2023 16:30 UTC](https://discourse.nodered.org/t/pzem-004t-via-espeasy/82580/19 "2023-11-16T16:30:59Z")

</div>

Of course now I only measure the difference of the neutral current and the phase current, which will be about 0.

My brain is still melted from the daily job. Will need my walk in the dark before continuing...

Thanks for the LIVE support 🙏

---

<div class="post-metadata">

### Author: ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)
#### Post date: [16 November 2023 23:12 UTC](https://discourse.nodered.org/t/pzem-004t-via-espeasy/82580/20 "2023-11-16T23:12:25Z")

</div>

A little bit of unexpected family stuff, so the me-time started about 5 hours later as expected...

But these 15 minutes were enough for a little test setup. The clamp is now only around the phase wire of a light bulb, and here we go:

![pzem](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/1/31707bf2470cb798beba20123bcbcdad65a86617.gif)

Now finally I can start measuring my electric circuits 🍾 🥂  
Thanks again for all the help!!!

[Next page](https://discourse.nodered.org/t/pzem-004t-via-espeasy/82580.md?page=2)
