h4 / lywsd02

MIT License
169 stars 34 forks source link

Issue with battery reading #8

Open krzyk opened 4 years ago

krzyk commented 4 years ago

Thanks for great work on debugging lywsd02. I started using it about 2 weeks ago and I notice strange thing with battery reading.

For the first three days it reported 100%, and then suddenly 72%, and on the same day it fell to 69%. Right now after 2 weeks it is at 37% reading.

I wonder if this is issue with parsing the battery data from the device or the device will use up the battery in 3 weeks?

I do a reading of the temperature/humidity every 5 mins, but I did the same on the other xiaomi device (LCD round one) and after 6 months of doing that the battery went from 100% to 71%.

After taking into account the difference of capacity between CR2032 and AA, LYWSD02 should have battery level at about 70% (and this is considering it was a LCD screen not an eink). I also have a CR2032 powered miflora, which used up ~6% of battery and I read it every 15 mins, so if I did it every 5 mins it would be ~24%.

So I wonder, what is a reason for that? Is there a chance for error in the battery reading?

seeschloss commented 4 years ago

Hi, I'm the one who added the battery reading code. As far as I understand, the reading is just very unreliable. In my case, one of the units went from 100% to 50% in about two weeks, and is now at 35% five months later. The other unit started at 50% (with new batteries) fell down to 40% in about the same timestamp and is now also at 35%.

I think it just falls down fast and then settles to a more reasonable drop rate. It's also totally possible that the reading is wrong, but I think it's just a basic voltage measurement that is then converted as a rough percentage. The curve does look like the voltage curve of a discharging battery, fast at first and then slowing down into a long plateau, so it should stay at around 35% for a long time I think.

krzyk commented 4 years ago

Thanks for explanation, now it went up to 41% :) I wonder if the temperature makes a difference for the reading, it was at 38% when I put it in 19 C and now when it is 23 it is at 41%.

BTW. I found that I had a bug and with each read of temperature/humidity I was also updating the clock, so it probably used up battery 2x as fast (or more).

But for sure I need to mount it using a manget instead of double-sided tape :)