5

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?

mhd
  • 535
  • 1
  • 5
  • 12

1 Answers1

4

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.

MasterHD
  • 2,264
  • 1
  • 32
  • 41
  • I guess you have to add the assumption the battery charging has the same speed as the battery discharging. Because 1 Ah / 1A = 1h. This is the time which the battery will generate 1A during of its discharging. Perhaps I'm not right because I don't know physics well. – mhd Nov 13 '14 at 11:22
  • An amp (Ampere) is a charge RATE with units of "Coulomb per second". For simpler numbers, the units of Ah have been chosen to measure actual amounts of charge (Coulombs). Ah/s is also a RATE. The battery discharge rate could be very different from the charge rate, but it would be calculated by: POWER_SUPPLY_CHARGE_NOW/(-POWER_SUPPLY_CURRENT_NOW). Again, this is the AVERAGE time remaining at constant current. You'll need to understand calculus basics if you want more accurate instantaneous rates. – MasterHD Nov 13 '14 at 13:24
  • I'm not sure if this changed recently, but I didn't have any properties related to CURRENT. However I did see POWER_NOW which seems to show how much of ENERGY_NOW is being taken away or added per hour. So dividing ENERGY_NOW by POWER_NOW will give you the hours remaining. – comfreak Jan 15 '19 at 22:12