How to calculate the time remaining until the end of the battery charge

3.7k views Asked by At

I have the following output:

$ cat /sys/class/power_supply/BAT0/uevent
POWER_SUPPLY_NAME=BAT0
POWER_SUPPLY_TYPE=Battery
POWER_SUPPLY_STATUS=Charging
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Li-ion
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=10800000
POWER_SUPPLY_VOLTAGE_NOW=12178000
POWER_SUPPLY_CURRENT_NOW=904000
POWER_SUPPLY_CHARGE_FULL_DESIGN=4042000
POWER_SUPPLY_CHARGE_FULL=4042000
POWER_SUPPLY_CHARGE_NOW=3916000
POWER_SUPPLY_MODEL_NAME=
POWER_SUPPLY_MANUFACTURER=HP
POWER_SUPPLY_SERIAL_NUMBER=

I want to calculate the time remaining until the end of the battery charge. Can I do it like this: (POWER_SUPPLY_CHARGE_FULL - POWER_SUPPLY_CHARGE_NOW) / POWER_SUPPLY_CURRENT_NOW? For this output the remaining time will be: (4042000-3916000) / 904000 = .13938053097345132743 an hour or 8 mins. Is this the correct formula to calculate the time remaining until the end of the charging?

1

There are 1 answers

3
MasterHD On BEST ANSWER

Since POWER_SUPPLY_CURRENT_NOW is in µA and POWER_SUPPLY_CHARGE_ are all in µAh then,

(POWER_SUPPLY_CHARGE_FULL - POWER_SUPPLY_CHARGE_NOW) / POWER_SUPPLY_CURRENT_NOW

will calculate the time in hours to reach POWER_SUPPLY_CHARGE_FULL, assuming that POWER_SUPPLY_CURRENT_NOW remains constant.