Battery Charge Level / Gauge

Discussion related to "under the hood" OpenMV topics.
IAmCoder
Posts: 7
Joined: Sun Jan 05, 2020 2:43 pm

Battery Charge Level / Gauge

Postby IAmCoder » Sun Jan 05, 2020 3:25 pm

Is there way to get the % of charge left in the battery?
User avatar
iabdalkader
Posts: 1214
Joined: Sun May 24, 2015 3:53 pm

Re: Battery Charge Level / Gauge

Postby iabdalkader » Sun Jan 05, 2020 5:43 pm

No there's no easy way to do that, you can use the ADC, but you need to lower the voltage to 0-VREF (~3.3v), this might be useful:
https://vivonomicon.com/2019/10/15/read ... tm32s-adc/
Nezra
Posts: 11
Joined: Fri Apr 19, 2019 9:08 am

Re: Battery Charge Level / Gauge

Postby Nezra » Mon Jan 20, 2020 4:52 pm

This is also a good read.

Hardware side:

https://docs.openmv.io/library/pyb.ADC.html


Software side:

If you can get the ADC vref, you can get the base voltage via the voltage divider (100/100) above by using the following formula will give you a decently accurate

(adc reading of battery/4095)*2(for the voltage divider) * 3.3(the 0-3.3v range) * ADC Reference Voltage(varies, but 1100 mv means use 1.1 sicne we are using volts; not millivolts))


From there, if you are using a random battery, you need to graph & monitor the discharge over and over. 4.2v is the "fully charged" voltage; and 3.2v is "fully discharged". However, it's not a linear equation since the battery will sit at 3.8v-3.7 for a majority of it's charge. the amount of current discharged impacts this as well. after its 3.7v it'll crash to dead very quickly.

Be aware, you aren't calculating the actual percentage, you are predicting how much is left via a mostly educated guess. for comparison, just because a cell phone says it has 50% battery left doesn't mean it's actually half left. phones do the same thing and adjust based on the battery's recent usage history based on some fairly standardized numbers from the battery itself. It's why your brand new phone has an amazing battery and after a few months it's horrible. nothing's really changed that much, other than the device learning and calculating it on it's own to give it a much more accurate view of the battery percentage "left".

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 7 guests