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

HOW TO RESET PZEM004TV3 ESP32? #107

Open
margohaux opened this issue Mar 13, 2023 · 1 comment
Open

HOW TO RESET PZEM004TV3 ESP32? #107

margohaux opened this issue Mar 13, 2023 · 1 comment

Comments

@margohaux
Copy link

margohaux commented Mar 13, 2023

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);
          }
        }
@mandulaj
Copy link
Owner

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

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

2 participants