Open MegoVaTx opened 10 months ago
Something like this.
#ifndef SENSOR_PZEM_TXPIN
#define SENSOR_PZEM_TXPIN GPIO_NUM_25
#endif
#ifndef SENSOR_PZEM_RXPIN
#define SENSOR_PZEM_RXPIN GPIO_NUM_32
#endif
#ifndef SENSOR_PZEM_ESP32_UART
#define SENSOR_PZEM_ESP32_UART 2
#endif
...
_serial = new HardwareSerial(SENSOR_PZEM_ESP32_UART);
_pzem = new PZEM004Tv30(_serial, SENSOR_PZEM_RXPIN, SENSOR_PZEM_TXPIN);
_pzem->readInputRegister();
double readout = _pzem->getVoltage();
readout =_pzem->getCurrent();
readout =_pzem->getPower();
readout =_pzem->getPowerFactor();
readout =_pzem->getEnergy();
readout =_pzem->getFrequency();
err =_pzem->getErrorState();
Please share the working code using your library.