How to connect pzem 017 DC with nodemcu

Yes I know, but there is already pwem-017 support in esphome.

nick, I’m no expert either, but I did play with rs485 stuff when I was helping my daughter’s swim team install some new scoreboards. As far as the protocol is concerned, it works exactly like UART. In fact, the scoreboards had a wireless option and an rs485 option. The rs485 option uses an adapter, which inside is just an ftdi chip connected to an opamp and optocouplers. The wireless dongle was nothing more than an ftdi connected to a 2.4 rf link (both methods use the same windows ftdi driver). Incidentally, my son’s baseball fields also got new wireless scoreboards last year that I helped install… same deal the old boards had rs485, and the new ones could use that, or a wireless link that has a module which plugs into the same port inside the scoreboards as the rs485 cable would go (no jumpers or other changes needed).

On the hardware side, it is essentially UART with a pair of 1.5V differential data lines (instead of the single ground reference line, which is vulnerable to noise). Usually they also use optocoupling to further eliminate ground loop noise. The differential signal, together with twisted pair wiring, makes rs485 capable of working reliably with 100m long cables. So you can think of rs485 like nothing more than a hardware attachment to boost your UART signal over long distances.

Since it’s 1.5V differential, it may be lucky and not necessarily harm an esp, but reliability could get dicey… and you run a risk of getting some bad inductance that might trash a GPIO pin. Bottom line, use a proper rs485 adapter and twisted pair wiring when communicating between an rs485 and uart device… and of course keep the uart wires as short as possible, and let the rs485 lines do the running.

Using a level shifter as peopsed by @cristi2005 is certainly the safest bet.

I still can’t figure out what @key5000 wants.

Hi Cristi,

I already saw that link and watched. The board he mentioned on his video is Arduino Mega and the board I am using is NodeMCU and EAP8266 mini D1. I did tried to modify the code but still doesn’t work.

Have you be able to make your PZEM-017 to work with Mini D1 and Arduino?

Hi truglodite,
The PZEM-004T and PZEM-017 are two different hardware and they use different code.

Hi Nickrout and all other expert,
What I want to achieve on this project is to use PZEM-017 with either ESP8266 Mini D1 or NodeMCU to give out the reading in Arduino so I can implement and view it with Blink app.

I need the code or sketch that can work on PZEM-017 and ESP8266 for Arduino.

Please help

So nothing to do with home assistant at all?

Hi Nickrout,

Will be in up coming month as I just bought another Raspberry Pi to setup the server. But in the mean time, i need this to run on Arduino/Blynk server.

Connect it directly to the arduino then. I cannot understand why you want to use an esp?

Yes, there is a video (post above) that show PZEM-017 with Arduino Mega but i’m looking for PZEM with ESP (has different hardward and output the the Mega) which also use Arduino code but and has WiFi build in.

Connecting the PZEM-017 to an ESP is exactly the same as connecting it to an arduino, except you have to allow for the fact that the ESP devices only use 3.3v on the signal pins. This is covered by the device @cristi2005 posted here How to connect pzem 017 DC with nodemcu

If you are using the software from the video, then you may need to adjust the pins.

I reiterate that your post seems to have nothing to do with either home assistant or esphome. I nevertheless hope that we have been able to help.

This is correct. I don’t have cod for arduino, only for esphome and my schematic is for that.

This is my code:

uart:
tx_pin: 1
rx_pin: 3
baud_rate: 9600
stop_bits: 2

sensor:

  • platform: pzemdc
    current:
    name: “Batery Current”
    id: dc_current
    voltage:
    name: “Batery Voltage”
    id: dc_voltage
    power:
    name: “Batery Power”
    id: dc_power
    update_interval: 1s

Hi there. I have the pzem 017 setup in home assistant. Is there a way to show the soc reading from the pzem. I wanted to be able to monitor state of charge in home assistant from this to then control for example turn off solar when battery hits 80% soc.

Were you able to do this? I’m looking for doing exactly the same thing and just found the device. I haven’t purchased it yet because I’m researching on how to use it with my epever solar charge controller and Home Assistant setup to do a more close to reality monitoring of the battery SOC.

Hey guys, I am trying to find the schematics of the peace fair module PZEM004T but not able to find any. Can someone please point me out in the right direction on this for where this schematic is available. I have searched google for 2 days or so. Thanks

Esp8266 is powered by a battery of solar panels. Is it possible to power PZEM-017 from the same solar panel battery source that I would like to measure?

This is how you can connect without additional boards by removing this element and soldering the jumpers. then there will be PZEM0XX Tx Pin B , Rx Pin A.

1 Like

Has anyone gotten ESPhome with the PZEM 017 to read “energy” (KWH)? Thanks
MikeyM

Yes, I use this code in esp8266:

uart:
  tx_pin: D2
  rx_pin: D1
  baud_rate: 9600
  stop_bits: 2

sensor:
  - platform: pzemdc
    current:
      name: "FV-Proud"
      filters:
        - calibrate_linear:
          - 0.0 -> 0.0
          - 2.1 -> 0.9
    voltage:
      name: "FV-Napětí"
      accuracy_decimals: 2
    power:
      name: "FV-Příkon"
      filters:
        - calibrate_linear:
          - 0.0 -> 0.0
          - 60.1 -> 25.6
      id: my_power
    update_interval: 5s
    
  - platform: total_daily_energy
    name: "FV-Energie"
    filters:
      - multiply: 0.001
    unit_of_measurement: kWh
    power_id: my_power
    
time:
  - platform: sntp
    id: my_time
2 Likes

Hello, can you please advise me how to connect PZEM-17 with D1-mini.I used a code from pepe59. I have an RS485 to TTL converter. I connected the output of Tx converter to Tx D1 mini and Rx to RX but it didn’t work. I also tried D5 and D6, only there will probably be a need to set up the serial software, because if I just connect TX to D5 and RX to D6, it doesn’t work. Thank you

uart:
tx_pin: 1
rx_pin: 3
baud_rate: 9600
stop_bits: 2
or
uart:
tx_pin: 14
rx_pin: 12
baud_rate: 9600
stop_bits: 2

You have a badly connected TX, RX.
Must be RS485-TTL TX on RX D1-mini and RX on TX D1-mini.
PZEM serial line - RS485 converter is A to A and B to B