mandulaj / PZEM-004T-v30

Arduino library for the Updated PZEM-004T v3.0 Power and Energy meter
MIT License
256 stars 108 forks source link

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

Open AlexGnatko opened 1 year ago

AlexGnatko commented 1 year ago

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):

Is there a way to debug this more deeply?

sergiocntr commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

@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:

ahmedreghini commented 1 year ago

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 commented 11 months ago

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 commented 11 months ago

@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