mandulaj/PZEM-004T-v30

HOW TO RESET PZEM004TV3 ESP32?

margohaux opened this issue · 1 comments

HI! I wanted to reset the energy but it does not work :( ...

if(thingspeak.readfloatfield(channel, apikey)==1){
            uint16_t u16CRC = 0xFFFF;                         /* declare CRC check 16 bits*/
            static uint8_t resetCommand = 0x42;               /* reset command code*/
            uint8_t slaveAddr =0X01;
            u16CRC = crc16_update(u16CRC, slaveAddr);
            u16CRC = crc16_update(u16CRC, resetCommand);
            preTransmission();                                           
            Serial.write(slaveAddr);                         
            Serial.write(resetCommand);                      
            Serial.write(lowByte(u16CRC));                    
            Serial.write(highByte(u16CRC));                   
            delay(10);
            postTransmission();                              
            delay(100);
          }
        }

Hey, have you tried using the resetEnergy function in the library?

Something along the lines of:

PZEM004Tv30 pzem(Serial);

psem.resetEnergy();

float energy = pzem.energy(); // -> 0