InfiniTimeOrg / InfiniTime

Firmware for Pinetime smartwatch written in C++ and based on FreeRTOS
GNU General Public License v3.0
2.69k stars 921 forks source link

Add a simple low pass filter for battery voltage #1513

Closed AlexXZero closed 1 year ago

AlexXZero commented 1 year ago

Sometimes I noticed that battery percentage might drops to 5-10%, then stay at the same level during a full day. During a little investigation I found that this behavior is related to noise in voltage measuring data. This PR should improve showing battery percentage by using low pass filter for battery voltage.

There is some data which I measured and used for comparing old and a new versions: Clear plot: image Findings: image Source data: battery.csv

On the plot you can see blue line is old data and orange line is a new data.

Summary of improvements:

  1. Battery discharge curve looks more stable without significant drops
  2. The start of the percentage drop is a little slow to make it more stable and match the rest of the discharge time
  3. 0% battery is when the watch stops working or about 1-2 hours after that.
Riksu9000 commented 1 year ago

0% is set to 3.5V, because you shouldn't discharge the battery too deep. ~This filtering causes the percentage to be overreported~ (It's the 0% at 3.2V change). SAADC has features to reduce noise. Let's try these before adding software filtering. https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf52832.ps.v1.1%2Fsaadc.html