---
title: "Optimizing energy consumption"
description: "Reduce the energy consumption of a low-power product: the microcontroller, firmware, GPIO and pull-ups, components, user interface, energy regression tests, and how to decide which change is worth making."
breadcrumb: "Low-power design"
url: "https://docs.joulescope.com/en/low_power/optimizing.html"
last_updated: "2026-11-28"
---

<a id="low-power-optimizing"></a>

# Optimizing energy consumption

You have designed your product and made your first measurements.  The odds
are that something does not work the way you intended.  Even the best
engineers forget a pull-up resistor, a reset condition or a regulator
power-up sequence.

Improve the design one change at a time:

1. Form a hypothesis about what consumes too much.
2. Make one change.
3. Measure the energy consumption.
4. Compare with the previous measurement, and decide what to do next.

This is the scientific method, applied to energy.  It works because every
step is a measurement, not a guess.  The sections below list where products
commonly waste energy, to help you form good hypotheses.  Start with what
the measurements show matters most; see
[Optimize what matters](#low-power-optimize-what-matters).

<a id="low-power-optimize-mcu"></a>

## Microcontroller

Peripherals
: Enable only the peripherals you need, and only while you need them.  The
  set changes with the operating mode, so firmware may need to enable and
  disable them dynamically.  Use peripheral clock dividers where possible.
  Remember to disable idle peripherals before entering sleep.

Run modes
: Halt the core when it has nothing to do, with wait-for-interrupt, and
  enter the lowest power state the product allows.  Include the time and
  energy that the microcontroller takes to wake up in your calculations.

Clock
: Power does not always scale linearly with clock frequency.  Flash wait
  states, for example, can make a faster clock less efficient for the same
  computation.  Measure to find the clock frequency that uses the least
  energy for your workload.  In the deepest sleep, switch to the lowest power
  oscillator.

Processors and microcontrollers
: In a system with an application processor, such as one running Linux,
  consider moving the functions that must run in low-power modes to a small
  microcontroller.  Waking a processor costs a lot of energy.  Waking a
  microcontroller for a few microseconds costs almost nothing.

<a id="low-power-optimize-software"></a>

## Firmware

* Profile first.  Most code does not matter for energy consumption.
  Initialization and error handling rarely do.  The code that runs all the
  time, in the normal flow, does.
* Reduce the time spent active.  In almost all cases, smaller, tighter,
  faster code consumes less energy, and layers of abstraction consume more.
* Do not spin-wait for long.  When the wait is longer than the time to
  switch from active to sleep and back, use a timer and an interrupt
  instead.  For many microcontrollers, that point is a few tens of
  microseconds.  A 10 ms spin-wait burns energy for no computation.
* Consider running performance-critical code from core-coupled RAM when
  flash has wait states.  Many microcontrollers execute from RAM at one
  instruction per clock.
* Minimize interrupts that wake the core.
* Use direct memory access (DMA) to move data while the core sleeps, for
  example to collect analog-to-digital converter (ADC) samples.  Many
  microcontrollers have hardware that runs peripherals without waking the
  core, under names such as Atmel® SleepWalking.

<a id="low-power-optimize-gpio"></a>

## Signals and GPIO

Pull-up and pull-down resistors
: Check every one.  With the product asleep, measure the voltage across each
  resistor.  Zero volts means zero current.  A single pull-up held at the
  wrong level can exceed the entire sleep budget, so make sure the signal’s
  lowest power state matches the pull direction.

GPIO configuration in sleep
: Configure every general-purpose input/output (GPIO) pin for sleep, with no
  conflicts between drivers.  The lowest power configuration is often an
  output driven low, but check the datasheet.

Regulator enable signals
: Drive them explicitly.  A floating enable can turn a regulator on
  intermittently, which causes unusual and hard-to-find behavior.

<a id="low-power-optimize-components"></a>

## Components

* Prefer components with low quiescent current, the current they draw when
  idle or asleep.
* Turn off what cannot sleep, with a load switch, a P-channel MOSFET or a
  power management IC.  Then check that nothing back-powers the components
  that are off; see [Arrange](https://docs.joulescope.com/en/low_power/design.md#low-power-design-arrange).  Be careful with
  multiple power domains that have separate regulator enables.
* Consider leakage, including the insulation leakage of bypass capacitors.
  Capacitors from reputable manufacturers are usually very good.  Parts of
  unknown origin can leak much more.  See [Leakage inside the target](https://docs.joulescope.com/en/theory/leakage.md#theory-leakage-inside).

<a id="low-power-optimize-ui"></a>

## User interface

Buttons
: Discrete buttons consume no current until pressed, which makes them the
  best choice for low power.  Capacitive touch can be reasonably low power,
  depending on the chip, so measure it.  If you use a button matrix, make
  sure a press interrupts the microcontroller, so the product does not have
  to scan the matrix in its lowest power mode.

Displays
: A display that must appear to stay on can be e-ink, which keeps its image
  with no power.

LEDs
: Many products want to light an LED in sleep, which can easily consume the
  whole sleep budget.  For a product with battery life measured in months or
  years, turn LEDs off in sleep.  Work with your customers and the people
  who write the requirements to find another way to show status.

<a id="low-power-optimize-process"></a>

## Development process

Energy consumption is a feature that any change can break.  A new firmware
feature written without energy in mind can consume the budget of the whole
product, so keep watching it throughout development:

* Create system or regression tests that measure energy consumption.  They
  show quickly when something breaks or changes.
* Track energy consumption as a metric over time.  If you have a
  continuous integration server, add a hardware-in-the-loop test that
  measures a real device on every build, so everyone on the team sees the
  effect of their changes.

The [joulescope_event_analyzer](https://github.com/jetperch/joulescope_event_analyzer)
package can turn a capture into a machine-readable summary for automated
tests, and compare two captures, such as two firmware versions.  To control
an instrument from a test, see [Software](https://docs.joulescope.com/en/software/index.md).

<a id="low-power-optimize-other"></a>

## Solder flux and board leakage

Solder flux that is not washed off the board has a high resistance, but it
can conduct enough to matter at microamp sleep currents.  If a board leaks
current and you cannot find where, wash one board in water, remove all the
flux residue, let it dry completely, and measure again.  If the sleep current
drops, address it in your assembly process.  For microamp sleep currents,
also keep the spacing between supply traces and other conductors as large
as possible.

<a id="low-power-optimize-what-matters"></a>

## Optimize what matters

Spend your time where the energy goes.  Eliminating a contributor that
consumes 1% of the energy still leaves 99%.  If a contributor consumes the
fraction *p* of the original energy *E*, and a change reduces it to the
fraction *f* of its original value, the new energy is:

$$
E_{NEW} = E \left( 1 - p + p \, f \right)
$$

Apply this to the [budget example](https://docs.joulescope.com/en/low_power/energy_budget.md#low-power-budget-example), which
averages 230.7 µA and meets its 180-day target only with the full rated
battery capacity:

| Change                                         |   *p* |   *f* | Average current   | Saving   |
|------------------------------------------------|-------|-------|-------------------|----------|
| Halve the Active/RF time, 5 s to 2.5 s         | 0.729 |   0.5 | 146.7 µA          | 36%      |
| Remove the LED                                 | 0.144 |   0   | 197.4 µA          | 14%      |
| Accelerometer sleep current from 20 µA to 2 µA | 0.086 |   0.1 | 212.8 µA          | 8%       |

Only halving the radio time meets the target with a battery derated to
80%: 227 days instead of 144.  The other changes may still be worth making,
but in order of their payoff.  The budget and the measurements tell you
which contributor is largest, so let them choose the next change.
