Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

The BatteryManager class doesn't have the metric for current: http://developer.android.com/reference/android/os/BatteryManager.html

And then I have found this post: http://stackoverflow.com/questions/2439619/getting-the-battery-current-values-for-the-android-phone It seems that the author also found it was not possible to get current value from the Linux entry.

I also downloaded the widget called CurrentWidget into my Nexus 7. For the current value, it shows "no data".

So probably a current sensor is required to get the current value and some android systems just do not have such sensors. Then how can the android system know the current battery level? Maybe it will just use the voltage of the battery to infer that(voltage will decrease during the discharge)? But then it would be very coarse-grained. Someone says that there is some 'trick' used to estimate the battery level without current values in Android(probably based on Voltage?). Is there any reference?

PS: for some reason, I know current value can be recorded on iphone 3GS

share|improve this question

1 Answer 1

up vote 6 down vote accepted

Battery level estimation is usually performed by a special “fuel gauge” chip; different phone models use different chips. E.g., Samsung GT-I8150 (Galaxy W), according to the kernel config, uses the Maxim MAX17043 chip, which, according to its datasheet, does not have any inputs to measure the current — it has only a battery voltage sensor. According to the manufacturer's description, this chip uses “a sophisticated Li+ battery-modeling scheme, called ModelGauge™ to track the battery’s relative state-of-charge (SOC) continuously over a widely varying charge/discharge profile”. Some information is available in the datasheet, but details of this “ModelGauge” scheme do not seem to be publicly available.

BTW, the driver used for Samsung Galaxy W seems to apply some corrections to the charge level returned by the MAX17043 chip, so probably the estimation performed by the chip is not ideal.

Other fuel gauge chips (e.g., MAX17047) measure both voltage and current, and sometimes also the battery temperature. Such chips can probably provide a more precise estimation of the battery charge level. Again, the datasheet does not provide all details of the used method.

However, even if the fuel gauge chip used in a particular phone can measure the current, accessing that information from Android might be impossible for several reasons:

  1. The chip might just use the current measurement internally and not expose it to the outside. This is not the case with MAX17047 — it has registers holding current measurement values, which can be read over the I2C bus.

  2. The kernel driver for the fuel gauge chip might not have code to expose the current measurement information to user applications.

  3. Even if the kernel driver makes the current measurement information available (e.g., through some sysfs file), Android does not have a standard API for such sensors — neither BatteryManager nor Sensor have anything appropriate for an electrical current sensor. Therefore the CurrentWidget app that you have found may work only on some models for which the developer has information about accessing this nonstandard sensor.

share|improve this answer
    
Hi,thanks so much. Your information is very helpful! I am very new to the android source code and kernel. Could you point me to the place where the driver for the chip of Nexus S is located....? So I can take a look and try to find out whether there is a way to get the battery level with higher resolution than using the Android API. This is just what I want to achieve. (From the document you provided, it seems that I can do this by reading the SOC register of the chip..) –  Hao Shen May 27 '13 at 14:27
1  
CONFIG_BATTERY_MAX17040max17040_battery.c; datasheet shows that this chip measures only voltage and not current, like MAX17043. –  Sergey Vlasov May 27 '13 at 15:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.