Sub topic 15
Cutting Average Current with Sleep Modes and Smarter Parts
The working model
This chapter assumes you can upload an Arduino sketch, read a simple circuit diagram, and use Ohm’s law. The goal is to reduce average current, which is the current a battery supplies over time. Battery life depends more on average current than on the highest short-term current.
A battery-powered project often has two states:
- Active: The microcontroller runs, sensors measure, and a radio may transmit.
- Sleep: Most circuits stop or slow down while waiting for the next task.
If a device is active for only a small part of each cycle, sleep mode can reduce its average current substantially.
Calculate the duty cycle
The duty cycle is the fraction of time that a device is active.
\[ I\text{average} = (I\text{active} \times t\text{active}) + (I\text{sleep} \times t\text{sleep}) \div (t\text{active}+t_\text{sleep}) \]
For example, suppose an Arduino and sensor draw 20 mA for 0.1 seconds every 10 seconds. During the remaining 9.9 seconds, the system draws 0.05 mA:
\[ I_\text{average} = (20 \times 0.1 + 0.05 \times 9.9) / 10 = 0.2495\text{ mA} \]
The active current is high, but the average current is about 0.25 mA.
Sleep modes on an Arduino
Sleep modes disable parts of the microcontroller. The deepest mode uses the least current, but it also disables more hardware. A timer, serial port, or analog-to-digital converter may not work until the chip wakes.
The following example uses the AVR watchdog timer on an Arduino Uno-compatible board. The watchdog wakes the chip about every eight seconds. The exact sleep features depend on the board’s microcontroller.
#include <avr/interrupt.h>
#include <avr/sleep.h>
#include <avr/wdt.h>
volatile bool woke = false;
ISR(WDT_vect) {
woke = true;
}
void setup() {
Serial.begin(9600);
MCUSR = 0;
WDTCSR = _BV(WDCE) | _BV(WDE);
WDTCSR = _BV(WDIE) | _BV(WDP3) | _BV(WDP0); // about 8 seconds
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
}
void loop() {
woke = false;
sleep_mode();
if (woke) {
Serial.println("Awake: measure, save, or transmit now");
}
}Choose low-power parts
Sleep code cannot compensate for unnecessary always-on current. Check the whole power path.
- Choose a regulator with low quiescent current, which is the regulator’s own operating current.
- Use indicator LEDs only when needed, or drive them briefly.
- Select sensors with a shutdown pin or one-shot measurement mode.
- Avoid unnecessarily strong pull-up resistors.
- Turn off unused peripherals and modules.
- Disconnect USB-to-serial hardware when measuring the board’s battery current.
Estimate the improvement
Measure active and sleep current with a multimeter or current meter. Then calculate average current from the duty cycle. Use the measured value for runtime estimates, because data sheets often omit LEDs, USB circuits, regulator losses, and startup bursts.
Exercise
A sensor draws 30 mA for 0.2 seconds every 20 seconds and 0.01 mA while sleeping. What is its average current?
Show answer
((30 × 0.2) + (0.01 × 19.8)) ÷ 20 = 0.3099 mA, or about 0.31 mA.