What's the unit of Battery current in sys/class/power_supply/battery/batt_current

5,151 views
Skip to first unread message

Nirjon

unread,
Nov 23, 2010, 1:37:32 PM11/23/10
to android-platform
Hi,

Could anyone give me a reference explaining the units of Battery information that are stored in: sys/class/power_supply/battery/ folder? 

Specifically, I need to know the unit of battery current.

Thanks in advance.

Shahriar Nirjon
University of Virginia. 

Rogério de Souza Moraes

unread,
Nov 23, 2010, 2:55:03 PM11/23/10
to android-...@googlegroups.com
Hi Nirjon,

current_now: uA
voltage_now: uV
temp: 0,125 * value = real degrees celcius
capacity: %
health: good, dead, Overheat, over voltage, unknown
Regards,

Rogerio


2010/11/23 Nirjon <nir...@gmail.com>
--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To post to this group, send email to android-...@googlegroups.com.
To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.

Nirjon

unread,
Nov 23, 2010, 3:58:16 PM11/23/10
to android-...@googlegroups.com
Hi Rogerio,

Are you saying that they are in "micro amp" and "micro volts"? Could you give me any reference about it so that I can cite that in my work?

Bests,
Shahriar Nirjon
University of Virginia 

2010/11/23 Rogério de Souza Moraes <rogeri...@gmail.com>



--
Nirjon.

Rogério de Souza Moraes

unread,
Nov 23, 2010, 4:05:11 PM11/23/10
to android-...@googlegroups.com
I took this information from Nexus One DS2782 driver.
The link for this driver code is bellow:

http://www.google.com/codesearch/p?hl=en#ogwwjCuGQDE/ds2784_battery.c&q=DS2784&sa=N&cd=1&ct=rc

Best regards,

Rogerio

2010/11/23 Nirjon <nir...@gmail.com>

Nirjon

unread,
Nov 23, 2010, 4:59:39 PM11/23/10
to android-...@googlegroups.com
Can't really agree with you. 

If you check line #118 and #325 of the link that you just provided, you'll see that they are converting it to mA and mV prior to printing it. How do I know for sure what they are printing in case of the values in /sys/class/power_supply/battery/... ? 

Bests,
Shahriar Nirjon
University of Virginia.

Kipling Inscore

unread,
Nov 23, 2010, 5:46:49 PM11/23/10
to android-...@googlegroups.com
On Tue, Nov 23, 2010 at 13:59, Nirjon <nir...@gmail.com> wrote:
> If you check line #118 and #325 of the link that you just provided, you'll
> see that they are converting it to mA and mV prior to printing it.

Line 118: seq_printf to debugfs, not sysfs.
Line 325: pr_info: printk(KERN_INFO,...) (include/linux/kernel.h), a
boot message (boot console, dmesg).

> How do I know for sure what they are printing in case of the values in
> /sys/class/power_supply/battery/... ?

line 683 (in function ds2784_battery_probe, which starts on line 654)
di->bat.get_property = battery_get_property;
This sets battery_get_property as the function responsible for
providing values for /sys/class/power_supply/battery/ files.
battery_get_property is defined on line 335. You can see that current
and voltage are not scaled or converted.

Also, any new enough Linux kernel should have
Documentation/power/power_supply_class.txt and
include/linux/power_supply.h both saying
All voltages, currents, charges, energies, time and temperatures in µV,
µA, µAh, µWh, seconds and tenths of degree Celsius unless otherwise
stated. It's driver's job to convert its raw values to units in which
this class operates.

So if any battery driver is reporting mA or mV in sysfs, it's probably wrong.

Nirjon

unread,
Nov 23, 2010, 6:18:41 PM11/23/10
to android-...@googlegroups.com
Hold on guys. I just have measured the voltage across the battery with a multimeter device and then from the sys/class/power_supply/battery, and I would like to confirm that the voltage is in mV. I have the multimeter reading = 4.02V and "cat batt_vol" (from adb shell) = 4103. I am using a HTC developer phone (model = AOSP on Sapphire, Firmware 2.1-update1). 

However, battery current is not so accurate: multimeter reading = 212 mA, and "cat batt_current" from shell = 455. I am not sure about the accuracy, but seems like it is reporting in mA.

Any thoughts/arguments/tips ? 

Bests,
Shahriar Nirjon
University of Virginia    

--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To post to this group, send email to android-...@googlegroups.com.
To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.




--
Nirjon.
Reply all
Reply to author
Forward
0 new messages