🛠 Low-power : power-down, watchdog et budget batterie
Objectives
The purpose of the Pro Mini: semi-permanent installation on battery ("intended for semi-permanent installation in objects or exhibitions"). We put the ATmega328P into power-down mode (its deepest of the 5 power-saving modes), wake it up every ~8 s via the independent watchdog, and also wake it up on button press via the external interrupt INT0 (pin 2). We address the battery budget: there is no USB chip on the board, so no FTDI bridge to power — this is the main advantage of this format over the Nano for the same ATmega328P.
Hardware
- 1 × Arduino Pro Mini (the 3.3 V/8 MHz model is best suited for LiPo batteries; the regulator accepts up to 12 V on RAW)
- 1 × 3.7 V LiPo battery on RAW, or external regulated 3.3 V on VCC
- 1 × micro-ammeter in series to measure the actual gain
- 1 × button between pin 2 (INT0) and ground, with internal pull-up
- >
Complete code
// Sommeil power-down + reveil watchdog ~8 s + bouton INT0 (broche 2)
#include <avr/sleep.h>
#include <avr/wdt.h>
#include <avr/interrupt.h>
ISR(WDT_vect) { /* reveil : retour naturel en loop */ }
ISR(INT0_vect) { /* reveil sur bouton, meme chemin */ }
void setup {
pinMode(13, OUTPUT);
pinMode(2, INPUT_PULLUP); // INT0 : reveil sur appui
MCUSR &= ~(1 << WDRF);
wdt_reset;
WDTCSR |= (1 << WDCE) | (1 << WDE); // acces config watchdog
WDTCSR = (1 << WDIE) | (1 << WDP2) | (1 << WDP1); // IT, ~8 s
EICRA = (1 << ISC01); // INT0 sur front descendant
EIMSK = (1 << INT0);
set_sleep_mode(SLEEP_MODE_PWR_DOWN); // ADC et BOD coupes dans ce mode
sei;
}
void loop {
digitalWrite(13, HIGH); // pouls de mesure
delay(50);
digitalWrite(13, LOW);
// ... ici : lecture capteur, mesure, envoi radio ...
wdt_reset;
WDTCSR |= (1 << WDCE) | (1 << WDE);
WDTCSR = (1 << WDIE) | (1 << WDP2) | (1 << WDP1); // rearme
sleep_enable;
sleep_cpu; // power-down jusqu'a WDT ou INT0
sleep_disable;
}
Expected verification
The micro-ammeter shows short spikes (the 50 ms LED pulse) separated by very low plateaus: the MCU alone drops from several milliamps when active to a few microamps in power-down mode. The LED blinks every ~8 s, proving that the watchdog successfully wakes the sleep; pressing the button immediately wakes the cycle. Removing the sleep code immediately raises the power consumption plateau.
Common errors
- Forgetting to rearm the watchdog at each cycle: on the second delay, the expiration switches to reset mode and the board restarts in a loop.
- Relying on the complete board for microampere measurements: the on-board linear regulator and power LED consume power continuously — the real gain is measured by removing the LED (or using a bare 328P with the same pinout).
- Leaving Serial.begin active: the UART and its buffers are costly; disable unused peripherals (power_adc_disable, etc.) before sleeping.
- Brown-out at end of battery life: a poorly calibrated BOD threshold (or clones with bad fuses) causes the board to restart in a loop as soon as the voltage under load drops below the threshold; measure the actual plateau under radio peak.
- Choosing a watchdog delay that is too short: each wake-up costs energy; group measurements and transmissions to maximize sleep time.
- >
Other tutorials for this board
Code examples for this board
clignotante.inoArduinobouton-poussoir.inoArduinopwm-fade.inoArduinocapteur-lumiere-ldr.inoArduinoservo-balayage.inoArduinoruban-neopixel.inoArduino