PZEM-004T V3 auto reset Energy usage each month

Hello all pro-programmers,

As we all know, the PZEM-004T V3 (see my project here) can accumulate and keep the energy usage up to 99999kWH.

Is it possible to have energy usage automatically RESET to zero at the end of each month?

Best regards and thank you inadvance.
Key

Pete.

Sorry, I forgot to mentioned that I did got the code from that post and integrated it to my code but for some reason, it does not reset.

Does that code automatic reset the reading at the end of each month or I have to build up the push button in Blynk to manually reset?

If it’s automatic reset each month then is there a way to keep any accumulate reading so I can see the total energy usage and monthly usage?

What I want is to see the energy usage each day, week, month and year if possible.

It’s simply a function, that you can call in anyway you wish - either via a hardware button, widget button, timed event etc.

Pete.

Hi Pete,

Since I’m not a programmer or code writer but willing to learn to build some smart project with Blynk, could you please point me to some source of example so I can learn and to make this goal alive.

I don’t have your hardware to test if this works, and I don’t necessarily have the same libraries installed, so I’m not going to write code that I can’t test.

Pete.

do you know any good sources or documentation for this time event function?

Hi Key,

Did you solve the problem? I’m looking the same. Could you mind to share the solution.

THanks,

This is the code that I used to manually reset the reading:

BLYNK_WRITE(V49)                                       // Virtual push button is defined as V4 of Blynk App. When the button is pushed, it will activate the codes  
        {
          if(param.asInt()==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();                                /* trigger transmission mode*/                
            Serial.write(slaveAddr);                          /* send device address in 8 bit*/
            Serial.write(resetCommand);                       /* send reset command */
            Serial.write(lowByte(u16CRC));                    /* send CRC check code low byte  (1st part) */
            Serial.write(highByte(u16CRC));                   /* send CRC check code high byte (2nd part) */ 
            delay(10);
            postTransmission();                               /* trigger reception mode*/
            delay(100);
          }
        }
1 Like

hi,
i have a problem with reset energy , i used nodeMCU
when i try to compile the program, i got error


could you give some advice.
thanks

I’m guessing that you don’t have the crc16h library installed from the GitHub repository linked in this post…

Pete.

uint8_t slaveAddr =0X01; Is this the default slave address for PZEM device?