jdeath/BLE-YC01

Battery reported incorrectly

Opened this issue · 4 comments

dwmw2 commented

The documentation shown in https://community.home-assistant.io/t/pool-monitor-device-yieryi-ble-yc01/418684/12 tells us that the device is reporting the battery voltage not its percentage.

	15	Battery voltage value high 8 bits
	16	Battery voltage value lower 8 bits

One of the early versions of the code divided by 45 to get to a percentage (is that a percentage of 4.5v, which is the nominal output of three alkaline AAA batteries?)

Later versions, and this code base, divide by 31.9 instead. But neither are correct because the relationship between voltage and "what's left" is non-linear. It looks more like this:
AA-100mA
(source: https://www.powerstream.com/AA-tests.htm )

At some point the batteries will be so low that the device will stop working. Maybe looking at the graph above that should be about 1v per cell, so maybe a value of 3000 would be the "zero" point? It's going to fall off a cliff shortly after that.

Let's pretend we can fit a straight line to the graph between full and that 1v cutoff. I know it's not quite true but it's not entirely awful.

So the battery percentage would go down from 100% at 4.5v, to 0% at 3v? The formula would look something like
( self.decode_position(decodedData,15) - 3000 ) / 15.0 ? And claim negative values to zero?

Except... right now my integration (using /31.9) is reporting 86.6% while the Android app reports 70%. That implies a raw value of something like 2762, so that zero point I guessed up there is clearly much too high.

We should probably gather more information about what the app says vs. the raw values we're seeing.

jdeath commented

Once you figure it out, please do a PR or provide an equation and I'll add it in.

dwmw2 commented

Will do. It would be useful if we can gather data from others. Otherwise I'll just watch my own battery deplete and base values on that.

dwmw2 commented

https://community.home-assistant.io/t/pool-monitor-device-yieryi-ble-yc01/418684/141 and
https://community.home-assistant.io/t/pool-monitor-device-yieryi-ble-yc01/418684/143 suggest that the app reports 0% battery when the reported voltage is about 60% of our 3.19v, so a raw value of about 1900.

(Remind me, does the device have two or three AA batteries? Mine's so sealed up tight with PTFE tape that I don't want to re-open it to check.)

So, if the 100% point is 3100 and 0% is 1950, my current reading (~2760) would be (2760-1950)/(3100-1950) = 70.4% which is fairly much what the app said.

So it would be self.decode_position(decodedData,15) - 1950 ) / 11.5 (and clamped between 0 - 100).

Let's continue to gather as much data as we can (and see if what the app reports is actually linear). Let's not make any changes to the code just yet, because it'll really confuse the data gathering if we have to know which version of the code people were using when they reported what it tells them vs. the app.

(Remind me, does the device have two or three AA batteries? Mine's so sealed up tight with PTFE tape that I don't want to re-open it to check.)

Hi @dwmw2 , the device has three AAA batteries.

Thank you!