🛠 Low-power : power-down, watchdog et budget batterie

Arduino Pro Mini · avance · Schéma : IMG-pro-mini-avance-9-promini-low-power-batterie.svg — Arduino Pro Mini sur LiPo avec bouton de réveil sur INT0 (broche 2), cycle de réveil watchdog ~8 s en mode power-down de l'ATmega328P, micro-ampèremètre en série

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

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

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials