views:

919

answers:

3

I am trying to collect power usage statistics for the Android G1 Phone. I am interested in knowing the values of Voltage and Current, and then able to collect statistics as reported in this PDF.

I am able to get the value of Battery voltage through registering for an intent receiver to receive the Broadcast for ACTION_BATTERY_CHANGED. But the problem is that Android does not expose the value of current through this SDK interface.

One way I tried is via sysfs interface, where I can view the battery current value from adb shell, using the following command

$cat /sys/class/power_supply/battery/batt_current
449 

But that too works only if the phone is connected via USB interface. If I disconnect the phone, I see the value of batt_current as '0'. I am not sure why the value of current reported is zero. It should be more than zero, right?

Any suggestion / pointers for getting battery current value? Also please correct me if I am wrong.

A: 

Here's some sample code that you could try.

Jay Askren
Thanks for the link, I am using similar function to read the Battery Voltage. But Android doesn't expose the value of current through that interface. So if you know some workaround at kernel / lower layer let me know.
Chintan
A: 

After several experiments and help from various other groups, I found out that there is no way of getting Battery Current value through software only (as its not supported in h/w). Only way I found was to measure current flowing through battery by means of multimeter.

Chintan
A: 

Strange !!

CurrentWidget is doing it and I'm also searching for such solution

loick