Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32-WROOM-32 (DOIT ESP32 DEVKIT V1) + PZEM-004T-100A(V3.0) - all returned values are NaN #100

Open
AlexGnatko opened this issue Dec 10, 2022 · 7 comments

Comments

@AlexGnatko
Copy link

Describe the bug
Can not use PZEM-004T-100A(V3.0) with ESP32

To Reproduce

  1. Copy/paste the HardwareSerial code snippet from README.md and create a sketch
  2. Connect PZEM-004T: 5V, GND, RX G16, TX G17
  3. Connect to 230V mains (checked with a voltmeter that the voltage is present)
  4. Compile/run the sketch on ESP32
  5. Observe the serial monitor

Expected behavior
Every two seconds I should see at least some output in the serial monitor, instead I see this:

Custom Address:0
Error reading voltage

Custom Address:0
Error reading voltage

Every two seconds the TX LED blinks on the PZEM-004T board. But all data returned by the PZEM004Tv30 object are NaN.

Desktop (please complete the following information):

  • Windows

Is there a way to debug this more deeply?

@sergiocntr
Copy link

Hi Alex ,welcome here.
In the example folder there is a sketch named change address :with that read your pzem address,maybe you set a wrong one in the constructor.

@iwas108
Copy link

iwas108 commented Jan 12, 2023

Any update on this? Because when I tried it with Arduino Nano on pin 11 and 12 it also returned address 0, error reading voltage.

@mandulaj
Copy link
Owner

Hey @AlexGnatko sorry for the late reply but try swapping the RX/TX pins. G16 (ESP RX pin) should be connected to the PZEM TX pin and vice versa.

@mandulaj
Copy link
Owner

@iwas108 First of all, the Arduino Nano, has only one hardware serial on pins D0 and D1 (generally used for sending things through the USB to your computer console) You will have to use Software serial with the pins 11 and 12. Check out the PZEMSoftwareSerial for more info. Once you do that, make sure to check the following:

  • The PZEM is connected to 230V
  • You have connected both the 5V and GND line correctly
  • Your RX/TX lines are connected the right way (if not sure, try swapping them)
  • You are using the correct unique address (if using multiple PZEMs on one Modbus line)

@ahmedreghini
Copy link

Hey @AlexGnatko sorry for the late reply but try swapping the RX/TX pins. G16 (ESP RX pin) should be connected to the PZEM TX pin and vice versa.

for anyone had this problem this is the right solution (thanks mr @mandulaj :) )

@jonathanpalomino
Copy link

jonathanpalomino commented Aug 2, 2023

pues a fecha de hoy yo tengo el mismo problema.
Custom Address:0
Error reading voltage

He intentado de todo y no logro hacer que reporte nada

@mandulaj
Copy link
Owner

mandulaj commented Aug 8, 2023

@jonathanpalomino Could you check that:

  1. The PZEMs are connected to the AC voltage
  2. The 5V and GND are connected correctly
  3. The RX/TX are connected correctly (also trying swapping them)
  4. The RX LED should blink every time the MCU tries reading flowed by the TX LED blinking with the response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants