esphome / media-players

This repo hosts known, tested devices that can server as media players to Home Assistant.
https://esphome.io/projects/?type=media
52 stars 22 forks source link

Added battery sensor #14

Closed bennop closed 2 years ago

bennop commented 2 years ago

When asking Olivier Ros about the possibility of a battery sensor in the Muse, I was told the hardware is already set up for this and got pointers to his code. With that information I attempted an implementation for the ESPHome version.

Everything works on my muse, however, as indicated in my initial comment, the readings are quite a bit off (max ~4.5V).

For now I adjust the my automation thresholds according to the discharge curve, at some point a more thorough calibration will follow ...

bennop commented 2 years ago

In the meantime I did perform the mentioned calibration. As I don't know how to add to an active pull request I'll post the corrected multiplier here:

#   - multiply: 0.00173913     # 2300 -> 4, for attenuation 11db, based on Olivier's code
    - multiply: 0.001637891    # after calibration

I would assume that value should work generally - within the accuracy of the divider and the ESP's ADC.

jesserockz commented 2 years ago

Did you try this with raw: false which provides a voltage based on factory calibrations? It might still need a simple multiplier though if there is a voltage divider in the circuit (I have not investigated and do not have a board to test)

bennop commented 2 years ago

Your second thought is what drove my approach. As I don't know (should have checked, though) the voltage divider, I did not use raw:false to stay as close as possible to Olivier's approach. Nonetheless, using his values my voltages were off by ~7% from what I expected so I did the calibration by measuring the voltage at the battery and compared with my readings using the initial parameter set. I used a 3.5 digit voltmeter and had readings within 10mV after the calibration - of course, I cannot make any such claims to it's validity on other boards ....

bennop commented 2 years ago

It's been six weeks without response - anything I can do?

davralin commented 2 years ago

Can confirm that this works for me also!