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

pzem-004t v3 reset energy alone after => 60kw #47

Closed
capblack opened this issue Jan 28, 2021 · 18 comments
Closed

pzem-004t v3 reset energy alone after => 60kw #47

capblack opened this issue Jan 28, 2021 · 18 comments
Assignees
Labels
bug Something isn't working hardware Issues related to hardware help wanted Extra attention is needed
Milestone

Comments

@capblack
Copy link

hello I built an energy meter of 3 faces with pzem-0004T v3 and I have the problem that the faces reset the accumulated energy after the 60kw approximately.
is a bug? thanks

https://youtu.be/ekmTViQi_cU

@mandulaj
Copy link
Owner

Hey @capblack thats very odd, the specs range should be 0-9999.99kWh according to the datasheet, but truth be told, I could not test it as I don't have such an energy consumption. The video though is private so I can't see it. Would you mind setting it as unlisted instead?

@capblack
Copy link
Author

OK thanks for you reply and, in the video you can see the unit , but not the reset in question, that is my average consumption per two months about 1200kw , but @ the start a say is very precise, after 100kw the star to show 30% less and after feew weeks 70% less , and i say there is a problem , and I see the ridings come to 0 after aprox pass 60 kw
Screenshot_2021-01-29-16-19-43-233_cc blynk

@mandulaj
Copy link
Owner

Hmm that is definitely a strange behavior... Sounds like some sort of a overflow. Could be in the PZEM or in the library code. I can't quite see anything obvious in the library code at the moment but I don't want to straight out blame it on the chip. I will have a closer look at this issue once I get around testing the library next week.

Unfortunately, I don't have power consumption quite high enough to test this thoroughly. I will try simulating it somehow but it would be really useful if you could send me the raw numbers that are coming from the PZEM chips.

Currently there is no debug mode (will add that to the TODO list). Would you be so kind and modify the library slightly in order to print out the raw response during the value update?

If you could add this code:

Serial.println("Raw response:");
for(int i = 0; i < 25; i++){
    Serial.println(response[i], HEX);
}
Serial.println("End");

after line 379 in the PZEM004Tv30.cpp library:

if(recieve(response, 25) != 25){ // Something went wrong
return false;
}
and send me the serial output for your devices with Energy over 60kWh.

Note that this will print the raw response from the PZEMs to the standard Serial device. Change it to what ever serial interface you use for debugging (like for example Serial2).

Temporary solution

In case you are reporting the energy to some sort of a database, you can set the code to reset the internal energy counter of the PZEMs with the .resetEnergy() method once it gets over a certain margin (60kWh). In the database, you can keep track, how many times you had to reset and from that calculate the true aggregate energy. It's not a perfect solution but in case it really is the limitation of the chip, it will be the only option.

I have had in mind for a while to perform a rigorous analysis of the true capabilities of the module and compare them to the manufacturer specifications. I would not be too surprised if the datasheet claims are slightly too optimistic.

@mandulaj mandulaj self-assigned this Jan 29, 2021
@mandulaj mandulaj added bug Something isn't working hardware Issues related to hardware help wanted Extra attention is needed labels Jan 29, 2021
@mandulaj mandulaj added this to the Release of v1.1 milestone Jan 29, 2021
@morganflint
Copy link

Maybe the OP is having a similar problem that was addressed here.
Basically, it was due to using only 2 of the 4 bytes of the energy registers, so it resets when it reaches 65532 Wh (65.5kWh).
That was with another library (ModbusMaster), I haven't analyzed if this one has the same problem, but it's suspicious the OP has the problem around the same "magic number"

@capblack
Copy link
Author

capblack commented Feb 28, 2021 via email

@brunosso
Copy link

brunosso commented Mar 7, 2022

I don't understand if this issue is fixed or not.
Thanks

@pioioTwo
Copy link

ia have problem, my code idem with examples

@pioioTwo
Copy link

my pzem its reset energy after 65 Wh

@capblack
Copy link
Author

yes i fix the problem , was the totals storage variable had an unsing_intiger, when I changed it to a long fix the bug :)

@pioioTwo
Copy link

can you give me an example

@mandulaj
Copy link
Owner

Yes @capblack, could you push your changes as a pull request. I am quite curious what the issue is. I had a look over the code and I am using uint32_t which should be large enough to hold the energy values.

If possible, I would like to avoid going to a long but perhaps its the unsigned nature that's causing the problem. Would have to investigate closer.

@capblack
Copy link
Author

capblack commented Mar 24, 2022 via email

1 similar comment
@capblack
Copy link
Author

capblack commented Oct 11, 2022 via email

@margohaux
Copy link

TTGO T-CALL ESP32 CODE??

@mandulaj
Copy link
Owner

@123salee could you please be a bit more specific? Is this related to this issue? Do you want example code? Do you have a problem?

@margohaux
Copy link

margohaux commented Nov 15, 2022 via email

@capblack
Copy link
Author

capblack commented Nov 15, 2022 via email

@mandulaj
Copy link
Owner

mandulaj commented Feb 2, 2023

Closing as resolved.

@mandulaj mandulaj closed this as completed Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hardware Issues related to hardware help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

6 participants