key
April 15, 2020, 11:51pm
1
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
key
April 16, 2020, 4:41pm
3
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.
key
April 16, 2020, 4:58pm
5
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.
key
April 16, 2020, 6:06pm
7
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,
key
December 25, 2020, 8:41pm
9
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
key:
crc16_update
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…
make a wiring connection for PZEM-004 v3.0 and ESP8266: (either NodeMCU and Wemos)
ESP8266 5V ==> PZEM 5V
ESP8266 G ==> PZEM GND
ESP8266 Rx ==> PZEM_Rx -> D6(GPIO12 - Tx)
ESP8266 Tx ==> PZEM_Tx -> D5(GPIO14 - Rx)
#include <SoftwareSerial.h>
SoftwareSerial pzem(14,12); // (RX,TX) connect to TX,RX of PZEM for ESP8266 bare board
void resetEnergy(uint8_t slaveAddr){
//The command to reset the slave's energy is (total 4 bytes):
//Slave address + 0x42 + CRC check high byte + CR…
Pete.
sri_c
March 4, 2024, 5:11am
12
uint8_t slaveAddr =0X01; Is this the default slave address for PZEM device?