JayB
JayB

Reputation: 397

Does battery voltage directly correspond to its level/percentage?

I found out that if you use getIntExtra("voltage", -1) in a broadcast receiver listening for ACTION_BATTERY_CHANGED. It gives you the mV. I have two questions actually.

1. Does anyone know of a way I can grab the voltage at any point in time without relying on the most recent update from my broadcast receiver?

2. Does anyone know if this value is reliable enough to use for measuring battery consumption over a time interval?

Upvotes: 0

Views: 1636

Answers (2)

MRodrigues
MRodrigues

Reputation: 2025

Android manufactures are responsible for implementing on their Android version, ROM the battery discharge model for the battery they are using, which will be later used by the Android SDK see here. You can also use

$ adb shell dumpsys batterystats

1 - I think the broadcast is the only way to get it. Some people refer that you cand read the file at /sys/class/power_supply/battery/batt_current but not all android phones have it.

2 - Based only on the voltage it's hard to calculate the battery consumption it's not a linear relationship, and different from battery to battery.

Upvotes: 0

J Richard Snape
J Richard Snape

Reputation: 20344

I can answer question 2 and the question in your title - most mobile devices use Lithium ion batteries and the raw voltage of the battery has a very non-linear relationship with how much capacity it has left (i.e. % charged / discharged).

Take a look at the graph here showing a Li-ion cell voltage against capacity left. You can see that voltage remains roughly constant (slight downward trend) from battery full to battery about 10% capacity and then sharply falls off.

@ChrisStratton points out in a comment that the graph is not for a modern device and says that they are substantially different and may be easier to infer state of charge from voltage. Unfortunately I could not find a link to similar graphs for a modern mobile phone battery. However, it can be seen that modelling state of charge from open circuit voltage (OCV-SOC) remains an active academic research topic.

The point still stands that using the voltage to estimate state of charge is non-trivial.

Upvotes: 1

Related Questions