Describe the bug
When the PZEM-004T-100A device is disconnected from the ESP32, the last successfully read values (voltage, current, power, energy) continue to appear in the Serial Monitor. This can lead to the false assumption that the device is still connected and reporting real-time values, even though the communication is lost.
To Reproduce
Steps to reproduce the behavior:
- Connect a PZEM-004T-100A sensor to the ESP32 and upload code similar to the following:
readings[0].voltage = pzemGridIn.voltage();
readings[0].current = pzemGridIn.current();
readings[0].power = pzemGridIn.power();
readings[0].energy = pzemGridIn.energy();
- Open the Serial Monitor to verify readings are being printed.
- Disconnect the PZEM-004T device from the ESP32 (e.g., unplug TX/RX or power).
- Observe that the Serial Monitor continues to show the last valid readings instead of reporting a failure or resetting to zero/null.
Expected behavior
Upon disconnection of the PZEM-004T device, the readings should reflect the loss of communication, such as returning NAN, zero, or triggering a fault status—rather than repeating stale values.
Desktop (please complete the following information):
OS: Windows 11
IDE: Arduino IDE 2.3.6
Board: ESP32 WROOM DevKit
Library Version: PZEM004Tv30 by Jakub Mandula 1.2.1
Additional context
This behavior may be due to the library returning cached values or failing silently on read errors. Adding explicit error handling (e.g., checking for isnan() or communication failure) might be needed to handle this edge case properly.
Describe the bug
When the PZEM-004T-100A device is disconnected from the ESP32, the last successfully read values (voltage, current, power, energy) continue to appear in the Serial Monitor. This can lead to the false assumption that the device is still connected and reporting real-time values, even though the communication is lost.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Upon disconnection of the PZEM-004T device, the readings should reflect the loss of communication, such as returning NAN, zero, or triggering a fault status—rather than repeating stale values.
Desktop (please complete the following information):
OS: Windows 11
IDE: Arduino IDE 2.3.6
Board: ESP32 WROOM DevKit
Library Version: PZEM004Tv30 by Jakub Mandula 1.2.1
Additional context
This behavior may be due to the library returning cached values or failing silently on read errors. Adding explicit error handling (e.g., checking for isnan() or communication failure) might be needed to handle this edge case properly.