Skip to content

Battery reported incorrectly #4

@dwmw2

Description

@dwmw2

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions