For many Internet of Things (IoT) applications, it is necessary to power devices using a battery. Whether your installation is deep inside a commercial freezer or atop a towering wind turbine, convenient outlets can be hard to come by in the real world.
The ability to deploy sensors in traditionally inaccessible locations is one of the major benefits of IoT, but relying on battery power comes with its own set of challenges.
For instance, one of our customers recently had a device go offline only a few months after installation.
The issue? Dead batteries.
One solution would have been to replace the batteries and move along. Which would have worked, but only temporarily. It turns out the hardware itself was faulty and was drawing too much power.
This blog post will help you understand how much power your IoT setup requires and enable you to predict its lifespan, two tools necessary for effectively deploying any battery-powered installation.
Why Power Consumption Matters
The ideal IoT sensor can be installed anywhere without wires, reports data whenever the user wants it, and runs indefinitely.
These competing needs are what make power management so important in IoT applications.
Another thing to keep in mind is that wireless communication is power intensive. The WiFi specification allows transmission power to vary between 100mW and 4W of power.
The most energy dense AA battery we can find only has 5000 mWh. Let’s say we have a 3V microcontroller and two AA batteries. With these figures, our device would only last a little over two days if it’s constantly transmitting!
Understanding Power Consumption
When investigating the power consumption of your IoT project, it can be helpful to measure the instantaneous power consumption of your application. You can do this by adding a small shunt resistor to the power supply of your microcontroller, and measuring the voltage across the resistor with an oscilloscope.
With this information you can start making power optimizations by disabling components using the following heuristic:
- Determine the maximum acceptable time a component can be offline based on application requirements.
- If the power to shutdown and start a component is less than the power to keep the component alive for that duration, shutdown the component and power it up on demand.
How to Measure Battery Lifespan
With the rise of laptops and smartphones, battery level indicators have become ubiquitous in everyday life.
Despite their prevalence, they’re still error prone, with devices turning off unexpectedly or the charge level jumping drastically in a matter of minutes.
The state of charge (SoC) is notoriously difficult to measure for a number of factors, including:
- the flatness of discharge curves with lithium based batteries
- repeated charge and discharge cycles changing a discharge curve over time
- battery temperature
There are advanced SoC measurement techniques (such as Coulomb counting or cell internal resistance measurement), but the most common low-power approach is simply measuring the voltage of the battery cell.
While this technique is effective, it is dependent on several variables that vary between applications:
- Minimum operating voltage – Your chosen microcontroller and circuits need the board voltage to stay within an expected range.
- Battery chemistry – Not only changing the type (Alkaline, NiMH, LiPo, etc), but even changing the brand of a battery will alter the battery chemistry.
- Battery capacity – Battery capacity is dependent on chemistry, cell size, and even brand.
- Ambient temperature – At colder temperatures, batteries leak less current when not in use, but the available power can be significantly lower.
- Discharge current – Batteries aren’t perfect power supplies, and wires aren’t perfect conductors. The discharge current impacts the apparent voltage at your circuit when you consider the battery as an imperfect supply and model it with a Thevenin equivalent circuit.
- Battery wear – Rechargeable batteries have a fixed number of charge and discharge cycles. The more cycles a battery goes through, the lower total charge it can store.
Using voltage as a proxy for SoC requires constructing a discharge curve which relates the battery voltage to the SoC.
Deriving this relationship is relatively straightforward once you’ve identified each of the variables above:
- Connect the analog to digital converter (ADC) to the battery power leads.
- Make your application log the battery voltage using the ADC at a fixed interval when the application checks the battery’s SoC.
- Fully discharge your chosen battery using your hardware.
- Graph your data to get a sense of the discharge curve
- Remove data points from the end of the curve that are from unstable behavior (i.e. shows a missed timestamp or clock slippage)
- Normalize the data so that time is 0 to 100
- Calculate SoC as 100 – normalized time
- Run a regression on the normalized data (your x value should be the measured voltage and your y value should the SoC)
- Select a curve that fits the data well.
- Generate your look up table
- Choose a power of 2 as your look up table size (the smaller the look up table, the less accurate the look up as the battery is further discharged)
- Solve your regression formula for each index in your lookup table
Methods to Reduce Power Consumption
Now that you have the tools to measure your application’s power consumption and predict its lifespan, let’s dive into methods for extending the battery life.
- Use the lower power capabilities of your microprocessor.
- Add sleeps to spin blocking behavior – a good rule of thumb is to use half the maximum acceptable delay as the sleep value.
- Disable the wireless transmitter when not in use for long periods of time.
- Disable unused peripherals.
- Use wide power supply traces on your circuit board.
- Include power rail capacitors to smooth out voltage dips on transient current spikes.
- Use high efficiency switching regulators rather than linear low-dropout regulators.
The Power of Power Consumption Monitoring
The perfect IoT sensor that is wireless, lasts forever, and is always connected, will never exist.
However, by using the tools outlined above, we can maximize the aspects of our application that are most critical to our goals.
If you’re interested in geeking out over SoC curves with us, or optimizing code for lower power consumption, check out our jobs page, we’re hiring!