Measure device power

You can determine device power consumption for Android devices that include a battery fuel gauge such as a Summit SMB347 or Maxim MAX17050 (available on many Nexus devices). Use the in-system gauge when external measurement equipment is not available or is inconvenient to connect to a device (such as in mobile usage).

Measurements can include instantaneous current, remaining charge, battery capacity at test start and end, and more depending on the supported properties of the device (see below). For best results, perform device power measurements during long-running A/B tests that use the same device type with the same fuel gauge and same current sense resistor. Ensure the starting battery charge is the same for each device to avoid differing fuel gauge behavior at different points in the battery discharge curve.

Even with identical test environments, measurements are not guaranteed to be of high absolute accuracy. However, most inaccuracies specific to the fuel gauge and sense resistor are consistent between test runs, making comparisons between identical devices useful. We recommend running multiple tests in different configurations to identify significant differences and relative power consumption between configurations.

Read power consumption

To read power consumption data, insert calls to the API in your testing code.

import android.os.BatteryManager;
import android.content.Context;
BatteryManager mBatteryManager =
(BatteryManager)Context.getSystemService(Context.BATTERY_SERVICE);
Long energy =
mBatteryManager.getLongProperty(BatteryManager.BATTERY_PROPERTY_ENERGY_COUNTER);
Slog.i(TAG, "Remaining energy = " + energy + "nWh");

Available properties

Android supports the following battery fuel gauge properties:

BATTERY_PROPERTY_CHARGE_COUNTER   Remaining battery capacity in microampere-hours
BATTERY_PROPERTY_CURRENT_NOW      Instantaneous battery current in microamperes
BATTERY_PROPERTY_CURRENT_AVERAGE  Average battery current in microamperes
BATTERY_PROPERTY_CAPACITY         Remaining battery capacity as an integer percentage
BATTERY_PROPERTY_ENERGY_COUNTER   Remaining energy in nanowatt-hours

Most properties are read from kernel power_supply subsystem attributes of similar names. However, the exact properties, resolution of property values, and update frequency available for a specific device depend on:

  • Fuel gauge hardware, such as a Summit SMB347 or Maxim MAX17050.
  • Fuel gauge-to-system connection, such as the value of external current sense resistors.
  • Fuel gauge chip software configuration, such as values chosen for average current computation intervals in the kernel driver.

For details, see the properties available for Nexus devices.

Maxim fuel gauge

When determining battery state-of-charge over a long period of time, the Maxim fuel gauge (MAX17050, BC15) corrects for coulomb-counter offset measurements. For measurements made over a short period of time (such as power consumption metering tests), the fuel gauge doesn't make corrections, making the offset the primary source of error when current measurements are too small (although no amount of time can eliminate the offset error completely).

For a typical 10 mOhm sense resistor design, the offset current should be better than 1.5 mA, meaning any measurement is +/-1.5 mA (PCBoard layout can also affect this variation). For example, when measuring a large current (200 mA) you can expect the following:

  • 2 mA (1% gain error of 200 mA due to fuel gauge gain error)
  • +2 mA (1% gain error of 200 mA due to sense resistor error)
  • +1.5 mA (current sense offset error from fuel gauge)

The total error is 5.5 mA (2.75%). Compare this to a medium current (50 mA) where the same error percentages give a total error of 7% or to a small current (15 mA) where +/-1.5 mA gives a total error of 10%.

For best results, we recommend measuring greater than 20 mA. Gain measurement errors are systematic and repeatable, enabling you to test a device in multiple modes and get clean relative measurements (with exceptions for the 1.5 mA offset).

For +/-100 uA relative measurements, required measurement time depends on:

  • ADC sampling noise. The MAX17050 with its normal factory configuration produces +/-1.5 mA sample-to-sample variation due to noise, with each sample delivered at 175.8 ms. You can expect a rough +/-100 uA for a 1 minute test window and a clean 3-sigma noise less than 100 uA (or 1-sigma noise at 33 uA) for a 6 minute test window.
  • Sample aliasing because of load variation. Variation exaggerates errors, so for samples with variation inherent in the loading, consider using a longer test window.

Supported Nexus devices

Nexus 5
Model Nexus 5
Fuel gauge Maxim MAX17048 fuel gauge (ModelGauge, no coulomb counter)
Properties BATTERY_PROPERTY_CAPACITY
Measurements The fuel gauge does not support any measurements other than battery state of charge to a resolution of %/256 (1/256th of a percent of full battery capacity).
Nexus 6
Model Nexus 6
Fuel gauge Maxim MAX17050 fuel gauge (a coulomb counter with Maxim ModelGauge adjustments), and a 10 mohm current sense resistor.
Properties BATTERY_PROPERTY_CAPACITY
BATTERY_PROPERTY_CURRENT_NOW
BATTERY_PROPERTY_CURRENT_AVERAGE
BATTERY_PROPERTY_CHARGE_COUNTER
BATTERY_PROPERTY_ENERGY_COUNTER
Measurements CURRENT_NOW resolution 156.25 uA, update period is 175.8 ms.
CURRENT_AVERAGE resolution 156.25 uA, update period configurable 0.7s - 6.4 h, default 11.25 secs.
CHARGE_COUNTER (accumulated current, nonextended precision) resolution is 500 uAh (raw coulomb counter read, not adjusted by fuel gauge for coulomb counter offset, plus inputs from the ModelGauge m3 algorithm including empty compensation).
CHARGE_COUNTER_EXT (extended precision in kernel) resolution 8 nAh.
ENERGY_COUNTER is CHARGE_COUNTER_EXT at nominal voltage of 3.7 V.
Nexus 9
Model Nexus 9
Fuel gauge Maxim MAX17050 fuel gauge (a coulomb counter with Maxim ModelGauge adjustments), and a 10 mohm current sense resistor.
Properties BATTERY_PROPERTY_CAPACITY
BATTERY_PROPERTY_CURRENT_NOW
BATTERY_PROPERTY_CURRENT_AVERAGE
BATTERY_PROPERTY_CHARGE_COUNTER
BATTERY_PROPERTY_ENERGY_COUNTER
Measurements CURRENT_NOW resolution 156.25 uA, update period is 175.8 ms.
CURRENT_AVERAGE resolution 156.25 uA, update period configurable 0.7s - 6.4 h, default 11.25 secs.
CHARGE_COUNTER (accumulated current, non-extended precision) resolution is 500 uAh.
CHARGE_COUNTER_EXT (extended precision in kernel) resolution 8 nAh.
ENERGY_COUNTER is CHARGE_COUNTER_EXT at nominal voltage of 3.7 V.
Accumulated current update period 175.8 ms.
ADC sampled at 175nbsp;ms quantization with a 4 ms sample period. Can adjust duty cycle.
Nexus 10
Model Nexus 10
Fuel gauge Dallas Semiconductor DS2784 fuel gauge (a coulomb counter), with a 10 mohm current sense resistor.
Properties BATTERY_PROPERTY_CAPACITY
BATTERY_PROPERTY_CURRENT_NOW
BATTERY_PROPERTY_CURRENT_AVERAGE
BATTERY_PROPERTY_CHARGE_COUNTER
BATTERY_PROPERTY_ENERGY_COUNTER
Measurements Current measurement (instantaneous and average) resolution is 156.3 uA.
CURRENT_NOW instantaneous current update period is 3.5 seconds.
CURRENT_AVERAGE update period is 28 seconds (not configurable).
CHARGE_COUNTER (accumulated current, nonextended precision) resolution is 625 uAh.
CHARGE_COUNTER_EXT (extended precision in kernel) resolution is 144 nAh.
ENERGY_COUNTER is CHARGE_COUNTER_EXT at nominal voltage of 3.7 V.
Update period for all is 3.5 seconds.