Battery Life & Current Consumption

Battery Life

How long will your project run on batteries? To answer that question you need to understand the capacity of your batteries and the amount of current consumed by your project.

Battery capacity is measured in milliamp-hours (abbreviated as mAh) which are a measure of how many hours a battery can sustain a constant draw of current. For example an 800 mAh battery can in theory provide 800 mA of current for an hour. However, in reality as current draw increases battery capacity decreases. Look for a datasheet from your battery manufacturer to see what the capacity of your batteries are at various current draws. For more information on batteries and battery capacity, check out this battery guide.

With the battery capacity and average current consumption, you can compute the expected runtime of your project by solving the equation:

Battery capacity (in mAh) / Average current consumption (in mA) = Hours of expected runtime

For example if your project consumes 150 mA and your batteries are rated at 800 mAh at that current draw, you can can compute:

800 mAh / 150 mA = 5.33 hours expected runtime

Current Consumption

For simple projects with a fairly constant current draw, a multimeter might be all you need to measure average current consumption. If you aren't familiar with how to use a multimeter to measure current, take a look at this multimeter guide for a great overview.

For more complex projects which have changing current demands, like this project, you'll want to measure current consumption over time. Using a series of current measurements you can compute an accurate estimate of average current consumption.

A great way to measure current over time is using this INA219-based current sensor breakout. If you aren't familiar with the INA219, be sure to read the guide on it's usage. The INA219 can be attached directly in series with the power input of your project and queried over an I2C interface to read current consumption. Using a device that can speak I2C, such as an Arduino, Raspberry Pi, or Beaglebone Black, you can record the current consumption of your project over time.

For this project I used an Arduino Yun connected to the INA219 breakout to log current consumption. A sketch running on the Yun talks to the INA219 and uses the Yun bridge library's Console class to send data to my computer over my WiFi network. A simple Python script runs on my computer to periodically record current measurements from the Yun.

The Yun is not very good at being a low-power device since its running Linux! For that reason we're using it just for tracking the power usage of our CC3000 setup
Above is a picture of the Yun and INA219 datalogger hardware I built. The code for this hardware is provided in the software download:
  • The Yun_INA219_Datalogger subdirectory is the Arduino sketch that should be loaded on the Yun hardware.
  • The Scripts/yun_ina219_datalogger.py file is the Python code to record measurements from the INA219 datalogger.
If you have a different Arduino, such as an Uno or Mega, check the sketch code for tips on how to convert it to write to the serial output with a few small changes.
One thing to note about the INA219, by default the software library assumes you want to measure a wide range of voltage and current with an accuracy of about 1 mA. If you know the voltage and current demands of your project are relatively low (under 16 volts and 400 mA), you can configure the INA219 for better accuracy of about 0.1 mA. Add this function to your INA219 library and call it instead of ina219SetCalibration_32V_2A() in the library's begin() function.
Last updated on 2015-05-04 at 04.27.56 PM Published on 2014-02-13 at 01.47.06 PM