🛠 Sommeil profond du SAMD21 pour nœud sur batterie

Arduino MKR WAN 1300 · avance · Schéma : IMG-mkr-wan-1300-avance-3-mkrwan-sommeil-bas-courant.svg — SAMD21 en sommeil profond avec RTC, batterie et microampèremètre

Objectives

Put the SAMD21 to sleep (deep sleep) and wake it up via RTC for a battery-powered node. Note: the 1300 does not have a Li-Po charger (unlike the 1310) — battery power is external. >

Hardware

Complete code

#include <RTCZero.h>

RTCZero rtc;
const uint8_t LED = 6;
volatile bool reveille = false;

void onAlarme { reveille = true; }

void setup {
  pinMode(LED, OUTPUT);
  rtc.begin;
  rtc.setAlarmTime(0, 0, 0);        // hh:mm:ss
  rtc.enableAlarm(rtc.MATCH_SS);    // toutes les minutes
  rtc.attachInterrupt(onAlarme);
}

void loop {
  // 1) Reveil : faire le travail radio (uplink LoRaWAN, cf. tutos precedents)
  digitalWrite(LED, HIGH);          // placeholder : acquisition + send
  digitalWrite(LED, LOW);

  // 2) Sommeil profond : STOP + WFI, le RTC reste seul actif
  SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
  __DSB;                          // evite la course reveil/sommeil
  __WFI;
}

Expected verification

The RTC alarm wakes the board every minute (brief LED flash); between alarms, the multimeter in series with the power supply drops significantly below the normal operating level. The LoRa module must also be put back to sleep via AT commands between transmissions.

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials