PZEM-004T v3 three-phase power energy is reset to zero by itself

Hello, I have a three-phase power meter running, with an esp32 and PZEM-004T v3 everything works fine except that the accumulated energy is reset to zero by itself when it exceeds 60 kw + - any idea what the problem is?
Thanks

The first problem is that you've not posted your code or circuit, so we have nothing to look at.

It sounds like wrap-around, perhaps using int where long would be appropriate?

Hello there is no problem with the code, but the circuit is only in my mind :slight_smile: nothing complicated 3 pzem-004v3 connected to the esp32 to each pair pins of the serial software and a small ac / dc 230vac to 5v from ebay that's all

Hello there is no problem with the code, but the circuit is only in my mind :slight_smile: nothing complicated 3 pzem-004v3 connected to the esp32 to each pair pins of the serial software and a small ac / dc 230vac to 5v from ebay that's all

Blynk-PZEM-004T-v3.0.ino (8.82 KB)

I want to add something like this to be able to manually reset the energy and see if it is solved

//BLYNK_WRITE(V49) // Virtual push button is defined as V4 of Blynk is pushed, it will activate the codes

void reset()
{
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);
pzem.write(slaveAddr); /* send device address in 8 bit*/
pzem.write(resetCommand); /* send reset command /
pzem.write(lowByte(u16CRC)); /
send CRC check code low byte (1st part) /
pzem.write(highByte(u16CRC)); /
send CRC check code high byte (2nd part) */
delay(10);
delay(100);
}

also attached secret.h

////////////////////////////////////////////////////////////
// Secret Configuration //
//////////////////////////////////////////////////////////

/***************************************************
Blynk Settings
**************************************************/

#define AUTH "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" // You should get Auth Token in the Blynk App.

/***************************************************
WiFi Settings
**************************************************/

#define WIFI_SSID "xxxxxxxx"
#define WIFI_PASS "xxxxxxxxx"

/***************************************************
Server Settings
**************************************************/

//#define USE_LOCAL_SERVER // Comment-out if use Blynk hosted cloud service
//#define SERVER "xxx.xxx.xx.xxx" // Comment-out if use Blynk hosted cloud service

#define PORT 8080

I test with this maybe is the problem

uint16_t data[6]
for
uint32_t data[6]

Now you've posted your code its easy to see the active_energy is a 16 bit MODBUS field, so will
wrap every 65536 (0x10000 hex)

I think you're meant to extend this by detecting the wrap-arounds and adding 0x10000 when you
see consecutive energy values decrease rather than increase.

Hello there is no problem with the code, but the circuit is only in my mind

Learn the lesson never to assume things like this - rule nothing out without solid evidence.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.