🛠 Sommeil bas courant et réveil sur interruption

Arduino MKR WAN 1310 · avance · Schéma : IMG-mkr-wan-1310-avance-3-mkrwan1310-sommeil-bas-courant.svg — MKR WAN 1310 sur batterie Li-Po endormie, icône lune, broche 16/A1 en pointillés reliée à un bouton de réveil, jauge 104 µA.

Objectives

Approach the documented floor of 104 µA for the MKR WAN 1310 (board-level, official store) by sleeping between two events: the core compiles this board with -DVERY_LOW_POWER, the Murata module drops to 1.40–1.65 µA in Stop/Standby (STM32L0 + SX1276 Sleep), and the SAMD21 offers deep modes with wake-up via external interrupt on pins 0, 1, 4, 5, 6, 7, 8, 16/A1, or 17/A2.

Hardware

Complete code

// Sommeil profond + reveil bouton — MKR WAN 1310 (SAMD21)
// > 
// l'approche EINT + attachInterrupt est documentee, pas le courant mesure.
volatile bool reveille = false;
const int REVEIL = 16;   // A1 : broche a interruption externe (EINT)
const int LED    = 6;

void onReveil { reveille = true; }

void setup {
  pinMode(REVEIL, INPUT_PULLUP);
  pinMode(LED, OUTPUT);
  Serial.begin(115200);
  attachInterrupt(digitalPinToInterrupt(REVEIL), onReveil, FALLING);
}

void loop {
  if (reveilles) {
    reveille = false;
    digitalWrite(LED, HIGH);
    Serial.println("Reveille !");     // ici : mesure + uplink LoRaWAN
    digitalWrite(LED, LOW);
  }
  dormir;                            // entre deux evenements
}

bool reveilles { return reveille; }

void dormir {
  noInterrupts;
  // Mettre le module LoRa en faible conso (AT+MODE/PSM selon firmware),
  // couper la LED, puis entrer en sommeil SAMD21 (mode Standby du core
  // ArduinoCore-samd compile avec VERY_LOW_POWER ; voir exemples Sleep.h).
  interrupts;
  // > 
  // le bouton reveille bien le sketch avant de compter sur l'autonomie.
  __WFI;   // attend l'interruption : approx. la porte du sommeil
}

Expected verification

Between two presses, the measured current drops significantly (documented target: 104 µA for the entire board, 1.4–1.65 µA for the module alone); a press on A1 wakes up the sketch, which prints and can transmit. The ON LED remains off on battery, which is normal: it follows the 5 V rail.

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials