How to wire pzem-017 thru 4 pin Max485 converter to nodemcuv3

1,704 views
Skip to first unread message

Khurram

unread,
Sep 17, 2021, 10:23:39 AM9/17/21
to TasmotaUsers
I am trying to get my pzem-017 to work with nodemcuv3 through a 4 pin Max485 transceiver module. The module 4 pins are connected as follows to the nodemcuv3:
Max485                NodeMCUv3          Tasmota
RO                                 D2                     PZEM017 Rx
DI                                   D3                    PZEM0xx Tx
RE                                 Gnd
DE                                 Gnd

All readings are 0 on the tasmota home screen. Can anyone help me out here?
Thanks

Philip Knowles

unread,
Sep 17, 2021, 11:11:20 AM9/17/21
to Khurram, TasmotaUsers

I think you can connect a single device direct to Tx/Rx without the MAX485 but you can definitely use an HW-655 without the MAX 485. There are details here how to mod the PZEM. PZEM-0xx power monitor - Tasmota

 

 

The PZEM works by Tasmota requesting the registers from the PZEM which then sends the information. Your wiring I looks to be set to receive only . Remember that the MAX485 needs 5V as does the PZEM.

 

Regards

 

Phil K

 

Sent from Mail for Windows

--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/ccf1c3bf-97bb-47a0-828b-bc94fe8b4d56n%40googlegroups.com.

 

Khurram

unread,
Sep 17, 2021, 11:31:56 AM9/17/21
to TasmotaUsers
I am aware of the link where you can "mod" the pzem-017 to make it work it directly with a nodemcu/wemos but it is not an option for me because of my limited soldering skills. The nodemcu, Max485 and pzem-017 are connected to +5V supply with common ground.

I could not find any information on how to wire RE and DE; therefore, I left them connected to ground. I also tried not connecting them and connecting them to +5V. It has made no difference.

Thanks

Philip Knowles

unread,
Sep 17, 2021, 11:49:58 AM9/17/21
to Khurram, TasmotaUsers

DE needs to be high to enable and RE needs to be low to enable

Khurram

unread,
Sep 17, 2021, 12:09:08 PM9/17/21
to TasmotaUsers
That did the trick, thanks a lot :)  I have 2 more questions:
1) Can I connect 2 opzem-017 to the nodemcu (I have already set them to different slave addresses)?
2) Is it possible to choose shunt value?

Thanks

Philip Knowles

unread,
Sep 17, 2021, 2:10:52 PM9/17/21
to Khurram, TasmotaUsers

You need to be very careful with PZEM-017s. The 0Vs on both PZEMs need to be the same if they are connected to the same Tasmota device otherwise you will get current flowing between the devices. If that is OK then it is possible to connect more than one but you’ll need to read the Power Management pages.

It’s a while since I’ve set up my PZEMs but I think you set the shunt value in the PZEM not Tasmota.

Khurram

unread,
Sep 17, 2021, 2:44:31 PM9/17/21
to TasmotaUsers


By 0Vs, do you mean the GND connection? My setup is a simple PWM charge controller with 3 pairs of connections: solar panel, battery and load (the positive terminal for each of these is common). My idea was to use 1 pzem-017 to read the load voltage and current and use the other pzem-017 to read the solar panel voltage and current. The tasmota device will be on the load side of the charge controller along with 1 of the pzems. Both pzem and the max485 will get power from a buck converter connected to the load side of the charge controller. I am not clear if this addresses the concern you raised above.

I know that you can set the shunt value on the pzem-017 itself. I was asking if there a command (setoption or something else) that can set the shunt value from tasmota?

Philip Knowles

unread,
Sep 17, 2021, 3:40:03 PM9/17/21
to Khurram, TasmotaUsers

That’s exactly the problem. The inputs are isolated from each other (and the battery). If you connect to one ESP8266 you get a current flow from one PZEM to the other. I found out the hard way with the wires burning out – fortunately I was using telephone wire. There’s a warning in the instructions not to use the PC USB to power the PZEM – that’s the reason why.

I’ve ended up with 3 separate ESP8266s (with separate PSUs) for wind, solar and output to the inverter. I used HW-655s as the level shifters to the PZEMs. They’ve been in about 18months  I have another PZEM (not fitted yet)  tp measure charge current which will be fitted to the same HW-655 as the output to the charger.

 

In the UK we avoid using the term ‘ground’ in case it’s confused with ‘earth’ on the mains side. So we have 12V (say) and 0V on DC and Live, Neutral and Earth on AC.

 

Although, in theory, you can change the shunt value in settings in Tasmota you will reduce the accuracy of the PZEM because the PZEM will not be working on its FSD range.

Khurram

unread,
Sep 18, 2021, 5:50:31 AM9/18/21
to TasmotaUsers
I must confess that I do not understand how the current will flow from 1 pzem to the other. At the same time, I do not want to burn anything :) So I will go with 1 pzem on the load side only. I will not be connecting the 5V external power to pzem as the charge controller will shut off the load connections at 10.5 V.

The only reason I wanted to a pzem on the solar side was to check how much current are the plates delivering; the voltage is not important as I am measuring it on the load side and it is the same across all three pairs of connections (solar, battery and load). I have tried reading current on the solar side with an ACS712 (30 amp version) but it gives garbage readings all the time (for example, the reading yesterday at midnight was 21 amps and now when the sun is shining in the afternoon, it is 23 amps while the reading on my dc meter is 12 amps).

I am not aware of HW-655. A quick google search shows a match for single channel relays with ESP-01. If so, how are you actually using them with the ESP8266
? My plan was to use a relay (controllable from the nodemcu) to turn 5V supply to the pzem on/off. Is this how you are using the HW-655?

I stand corrected in my terminology about DC signals. 12V and 0V is a definitely better way to refer to the DC positive and negative.

Thanks.

Philip Knowles

unread,
Sep 18, 2021, 9:17:54 AM9/18/21
to Khurram, TasmotaUsers

If you are powering the PZEM only via the sensing terminals you will probably be OK. The 0V on the USB input and the 0V on the sensing terminal are connected. If you connect 2 PZEMs to the same PSU you bridge the 2 circuits together (which are isolated from each other by the charge controller). That’s why you can get a current flowing.

 

One of the things I found out when I was setting mine up is the realisation that the battery (on the output from the charge controller) was the ‘load’ which means putting it in a slightly different place in the circuit.

 

The HW-655 has a 5V input and has 5V Tx Rx and 0V on a pin header. There is a voltage shifter to allow RS485 comms directly from the header. I’m not using the relay at all on mine. Mike Ingraham produced a How to based on what I did here PZEM-0xx power monitor - Tasmota

 

Regards

 

Phil K

 

Sent from Mail for Windows

 

From: Khurram
Sent: 18 September 2021 10:50
To: TasmotaUsers
Subject: Re: How to wire pzem-017 thru 4 pin Max485 converter to nodemcuv3

 

I must confess that I do not understand how the current will flow from 1 pzem to the other. At the same time, I do not want to burn anything :) So I will go with 1 pzem on the load side only. I will not be connecting the 5V external power to pzem as the charge controller will shut off the load connections at 10.5 V.

 

The only reason I wanted to a pzem on the solar side was to check how much current are the plates delivering; the voltage is not important as I am measuring it on the load side and it is the same across all three pairs of connections (solar, battery and load). I have tried reading current on the solar side with an ACS712 (30 amp version) but it gives garbage readings all the time (for example, the reading yesterday at midnight was 21 amps and now when the sun is shining in the afternoon, it is 23 amps while the reading on my dc meter is 12 amps).

 

I am not aware of HW-655. A quick google search shows a match for single channel relays with ESP-01. If so, how are you actually using them with the ESP8266

? My plan was to use a relay (controllable from the nodemcu) to turn 5V supply to the pzem on/off. Is this how you are using the HW-655?

 

I stand corrected in my terminology about DC signals. 12V and 0V is a definitely better way to refer to the DC positive and negative.

 

Thanks.

On Saturday, 18 September 2021 at 00:40:03 UTC+5 knowles...@gmail.com wrote:

That’s exactly the problem. The inputs are isolated from each other (and the battery). If you connect to one ESP8266 you get a current flow from one PZEM to the other. I found out the hard way with the wires burning out – fortunately I was using telephone wire. There’s a warning in the instructions not to use the PC USB to power the PZEM – that’s the reason why.

I’ve ended up with 3 separate ESP8266s (with separate PSUs) for wind, solar and output to the inverter. I used HW-655s as the level shifters to the PZEMs. They’ve been in about 18months  I have another PZEM (not fitted yet)  tp measure charge current which will be fitted to the same HW-655 as the output to the charger.

 

In the UK we avoid using the term ‘ground’ in case it’s confused with ‘earth’ on the mains side. So we have 12V (say) and 0V on DC and Live, Neutral and Earth on AC.

 

Although, in theory, you can change the shunt value in settings in Tasmota you will reduce the accuracy of the PZEM because the PZEM will not be working on its FSD range.

 

Regards

 

Phil K

 

 

Sent from Mail for Windows

 

From: Khurram
Sent: 17 September 2021 19:44
To: TasmotaUsers
Subject: Re: How to wire pzem-017 thru 4 pin Max485 converter to nodemcuv3

 

 

By 0Vs, do you mean the GND connection? My setup is a simple PWM charge controller with 3 pairs of connections: solar panel, battery and load (the positive terminal for each of these is common). My idea was to use 1 pzem-017 to read the load voltage and current and use the other pzem-017 to read the solar panel voltage and current. The tasmota device will be on the load side of the charge controller along with 1 of the pzems. Both pzem and the max485 will get power from a buck converter connected to the load side of the charge controller. I am not clear if this addresses the concern you raised above.

 

I know that you can set the shunt value on the pzem-017 itself. I was asking if there a command (setoption or something else) that can set the shunt value from tasmota?

To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers..@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.

--

You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.

Khurram

unread,
Sep 18, 2021, 4:56:31 PM9/18/21
to TasmotaUsers


Ok, I will try with wiring both the pzems to the nodemcu and see how it goes. As it stands, I find the pzem-017 to be a nightmare as compared to pzem-04t. I have 2 units and they work intermittently. Sometime I get non-zero readings on the tasmota page and sometimes I dont. I am testing 1 pzem at a time and both show this behavior. I am powering the nodemcu (plugged into a nodemcu base) through a pc usb port and the pzem through the nodemcu base. Could it be a power issue?

I am no clear on this. I am not connecting anything to the charge controller battery terminals. 1 pzem will be on charge controller load terminals: it will get its power from a buck converter which is also connected to the charge controller load terminals, its shunt will be measuring voltage and current on the charge controller load terminals and its A/B will be connected to the max485 converter. The nodemcu tx/rx are connected to the max485 tx/rx ttl side; both the nodemcu and max485 get their power from the buck converter. The 2nd pzem will also gets it power from the buck converter, it shunt will be connected to the charge controller solar terminals, its A/B will connect straight to 1st pzem A/B.

I think you are using HW-665 to isolate the rx/tx lines. I guess I could do the same using an optocoupler but I haven't reached that stage yet. I think the max485 might actually be  doing the isolation part but I am not sure.

Thanks
Khurram

Philip Knowles

unread,
Sep 19, 2021, 1:47:29 AM9/19/21
to Khurram, TasmotaUsers
You are going to do the thing which cause the current to flow through the sensor wires. The PZEMs are on different sides of the charge controller. The buck converter will then join them together. Either get another buck converter or just use the load or solar side without a buck converter. The PZEM will start working when the voltage goes over 7V. The load side of charge converters are generally 'sinks' (they don't source the DC they connect the -ve side of the load to 0V). That means that you can use the battery as the power for the PZEM and install the shunt goes between load -ve and the charge controller terminal.
The RS485 is already optoisolated from the sensing side. The 5V on the RS485 side is used to power the MAX485 within the PZEM. In my case the HW-655 is used to level shift the ESP-01 to RS485 signal levels.
My PZEMs are generally steady so perhaps it may be power or MAX485 issues.
I'll try to draw up a wiring diagram later today.

Regards

Phil K


From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of Khurram <kfha...@gmail.com>
Sent: Saturday, September 18, 2021 9:56:31 PM
To: TasmotaUsers <sonof...@googlegroups.com>

Philip Knowles

unread,
Sep 19, 2021, 3:39:57 AM9/19/21
to Khurram, TasmotaUsers

Khurram

unread,
Sep 19, 2021, 12:17:54 PM9/19/21
to TasmotaUsers
Thanks for the schematic. I have added/modified the schematic to show all the devices that I would like to connect. Could you please take a look at it and let me know if its ok.



Thanks
Khurram
MainEnclosure.jpg

Philip Knowles

unread,
Sep 19, 2021, 4:07:17 PM9/19/21
to Khurram, TasmotaUsers

That may be OK. You’ll need to check that the DC-DC buck converters are isolated from input to output (a lot are not).  You would be better powering the NodeMCU and PZEMs from the battery as the load will turn off at the low battery point. They won’t unduly drain the battery.

As I said you can connect the sensing -ve on the load PZEM to the battery -ve and dispense with the second buck converter. You will get a voltage reading when it’s switched off but there will be no current. That will be useful in itself because you will know the battery voltage. If you do that the PZEM1 and NodeMCU would be powered from the buck converter.

Khurram

unread,
Sep 19, 2021, 5:38:34 PM9/19/21
to TasmotaUsers
Thanks for your help. I do not mind if the NodeMCU and pzems turn off on low battery condition; hopefully it wont reach that stage. The isolation requirement for buck converter is a tough one here; the ones I have are not isolated. If I go with 1 pzem only (on the load side), would it be ok if the buck converter is not isolated?

I also have another problem communicating with the pzem. In the console window, I get the following continuously (after setting weblog to debug):
                PDC: PzemDc 1 error 7
I could not find any matches in google. The tx and rx leds on the max485 blink continuously (I changed the converter to the one shown in https://github.com/arendst/Tasmota/issues/3694#issuecomment-429898061). Tasmota is configured as follows:

tasmota config.png

  I have used the same gpio assignments as in the link above but the behavior is the same. What am I doing wrong?

Thanks,
Khurram

Philip Knowles

unread,
Sep 20, 2021, 2:38:38 AM9/20/21
to Khurram, TasmotaUsers

There’s an issue on Tasmota which suggests you need diodes in the Tx line.

Adding support for PZEM004T energy monitor for 3 phase - request · Issue #2315 · arendst/Tasmota (github.com)

To be honest I would supply a buck from the battery to power the NodeMCU and the Load PZEM. I would not bother with a buck for the solar side. As soon as the solar goes above 7V (which happens at low light levels) the PZEM will start to function.

 

Regards

 

Phil K

Sent from Mail for Windows

 

From: Khurram
Sent: 19 September 2021 22:38
To: TasmotaUsers
Subject: Re: How to wire pzem-017 thru 4 pin Max485 converter to nodemcuv3

 

Thanks for your help. I do not mind if the NodeMCU and pzems turn off on low battery condition; hopefully it wont reach that stage. The isolation requirement for buck converter is a tough one here; the ones I have are not isolated. If I go with 1 pzem only (on the load side), would it be ok if the buck converter is not isolated?

 

I also have another problem communicating with the pzem. In the console window, I get the following continuously (after setting weblog to debug):

                PDC: PzemDc 1 error 7

I could not find any matches in google. The tx and rx leds on the max485 blink continuously (I changed the converter to the one shown in https://github.com/arendst/Tasmota/issues/3694#issuecomment-429898061). Tasmota is configured as follows:

 

Khurram

unread,
Sep 20, 2021, 4:42:55 PM9/20/21
to TasmotaUsers
That article is for the pzem-004t. Does it apply to the pzem-017 also? I don't have any schottky diodes at the moment; I will try to get them tomorrow and try it out. By the way, the diode+resistor based network seems to be for the max converter mentioned at https://github.com/arendst/Tasmota/issues/3694#issuecomment-429898061. I have nothing but trouble with this converter; maybe my piece is faulty. I have since moved back to the 4 pin max485 converter mentioned in my first post. The nodemcu detects the pzem reading without any problems. Now on to the next step to check readings from 2 pzems.

I don't understand why I would not need a buck converter for the RS485 supply side of the solar pzem-0017. My setup is 12V. If I just wire the solar pzem-017 RS485 side supply signals directly to the solar + and -, won't it blow up the pzem once the solar plates voltage increase beyond 5V?

Thanks
Khurram

Philip Knowles

unread,
Sep 20, 2021, 5:09:32 PM9/20/21
to Khurram, TasmotaUsers

The PZEM-004T V3 is RS485 – that’s why it says to use the PZEM-016/7 driver in that article.

The PZEM doesn’t need a PSU plugged into the microUSB once the voltage is over 7V as it will take the voltage from the sensor input (not the RS485 side). The 0V on the microUSB is connected to the battery -ve terminal on the sensor side. That’s the reason why you can have problems with 2 PZEMs which do not have a common 0V – and why they say not to use a PC USB to power it. The label on the bottom the unit says “When the input test voltage is <7V, please use USB port to be the power supply”. The solar panels will easily generate 7V at low light levels.

The Schottky diode is to limit the ‘reflections’ on the data line as there is no termination on the line.

 

Regards

 

Phil K

 

Sent from Mail for Windows

 

From: Khurram
Sent: 20 September 2021 21:42
To: TasmotaUsers
Subject: Re: How to wire pzem-017 thru 4 pin Max485 converter to nodemcuv3

 

That article is for the pzem-004t. Does it apply to the pzem-017 also? I don't have any schottky diodes at the moment; I will try to get them tomorrow and try it out. By the way, the diode+resistor based network seems to be for the max converter mentioned at https://github.com/arendst/Tasmota/issues/3694#issuecomment-429898061. I have nothing but trouble with this converter; maybe my piece is faulty. I have since moved back to the 4 pin max485 converter mentioned in my first post. The nodemcu detects the pzem reading without any problems. Now on to the next step to check readings from 2 pzems.

 

I don't understand why I would not need a buck converter for the RS485 supply side of the solar pzem-0017. My setup is 12V. If I just wire the solar pzem-017 RS485 side supply signals directly to the solar + and -, won't it blow up the pzem once the solar plates voltage increase beyond 5V?

 

Thanks

Khurram

 

On Monday, 20 September 2021 at 11:38:38 UTC+5 knowles...@gmail.com wrote:

There’s an issue on Tasmota which suggests you need diodes in the Tx line.

Adding support for PZEM004T energy monitor for 3 phase - request · Issue #2315 · arendst/Tasmota (github.com)

To be honest I would supply a buck from the battery to power the NodeMCU and the Load PZEM. I would not bother with a buck for the solar side. As soon as the solar goes above 7V (which happens at low light levels) the PZEM will start to function.

 

Regards

 

Phil K

Sent from Mail for Windows

 

From: Khurram
Sent: 19 September 2021 22:38
To: TasmotaUsers
Subject: Re: How to wire pzem-017 thru 4 pin Max485 converter to nodemcuv3

 

Thanks for your help. I do not mind if the NodeMCU and pzems turn off on low battery condition; hopefully it wont reach that stage. The isolation requirement for buck converter is a tough one here; the ones I have are not isolated. If I go with 1 pzem only (on the load side), would it be ok if the buck converter is not isolated?

 

I also have another problem communicating with the pzem. In the console window, I get the following continuously (after setting weblog to debug):

                PDC: PzemDc 1 error 7

I could not find any matches in google. The tx and rx leds on the max485 blink continuously (I changed the converter to the one shown in https://github.com/arendst/Tasmota/issues/3694#issuecomment-429898061). Tasmota is configured as follows:

 

 

  I have used the same gpio assignments as in the link above but the behavior is the same. What am I doing wrong?

 

Thanks,

Khurram

 

--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.

--

You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.

Khurram

unread,
Sep 21, 2021, 3:45:01 AM9/21/21
to TasmotaUsers
Thanks for the clear explanation. To be clear, in case of the solar pzem-0017, I just need all the shunt side connections and only the A/B connections on the sensor side (to the max485). In case of the load pzem, I will wire all the shunt side connections to the charge controller load +ve and -ve (as shown in my diagram earlier); for the sensor side, A/B go to max485 and +5V and GND connect to buck converter output.

By the way, I replaced power supply to pzem from a nodemcu base to a 5V adapter (along with going back to the 4 pin RS485 adapater) and its working very well now. The readings are stable and changes are nearly instantaneous. Now I have to test it with 2 pzems and see how it goes. Then the next step would be to enable deep sleep on the nodemcu and write a rule to publish the pzem data on wakeup.

Thanks
Khurram

Philip Knowles

unread,
Sep 21, 2021, 6:08:49 AM9/21/21
to Khurram, TasmotaUsers

Yes you need the shunt side connections but you also need to use the 5V and 0V connections on the RS485 side. The RS485 side is isolated form the sensing side and needs to be powered. The power should come from the MAX485 as a ‘daisy chain’.

Khurram

unread,
Sep 21, 2021, 9:22:16 AM9/21/21
to TasmotaUsers
The MAX485 get its power from the buck conveter connected to the charge controller load +ve and -ve terminals. So I will just wire up so the buck converter supplies power to the nodemcu, MAX485 and both the pzems (RS485 side only).

Philip Knowles

unread,
Sep 21, 2021, 9:31:17 AM9/21/21
to Khurram, TasmotaUsers

Yes, but I would use the Battery terminals as the Load terminals may switch off (despite the Solar having an input). This could cause issues with the ESP

Khurram

unread,
Sep 21, 2021, 9:48:02 AM9/21/21
to TasmotaUsers
Yes, I read your view on this above. In my case, there is very low chance of load terminals switching off as I have ample battery storage and very low consumption (this set up is in the farmhouse which is only occupied for a few day every couple of months or so and is used to power a router, a raspberry pi and 2 ip cameras).

Khurram

unread,
Sep 22, 2021, 1:39:41 AM9/22/21
to TasmotaUsers
Just a little note here on the RS485 to USB converter that I was trying to used on my PC. I was using QModBus to read/write registers and it just would not communicate with the pzem-017. After reading https://github.com/EnviroDIY/SensorModbusMaster/issues/14, I just added a 68 ohm resistor (thats what I had available) to the A/B terminal block and it started working with QModBus.

Philip Knowles

unread,
Sep 22, 2021, 1:49:00 AM9/22/21
to Khurram, TasmotaUsers

That’s the ‘reflection’ issue that the Schottky diode fixes. The resistor terminator doesn’t always work.  

Reply all
Reply to author
Forward
0 new messages