Go Down

Topic: Using external interrupt to wake up board during standby mode (Read 1 time) previous topic - next topic


Hi all, I am using a RTCZero library to put the board into standby mode every 10 seconds and when the board wakes up, the LED will blink. Now I want to add an external interrupt to wake up the board even during the standby mode. How should I do? I have looked many posts online and tried some codes but it seems that the external interrupt only works when the board is wake up from standby mode. Following is my code. Any suggestions are appreciated!!

Code: [Select]
#include <RTCZero.h>

RTCZero rtc;

const byte seconds = 0;
const byte minutes = 00;
const byte hours = 00;

const byte day = 15;
const byte month = 7;
const byte year = 19;

bool matched = false;

void setup()
  pinMode(2, OUTPUT); //set LED pin to output
  pinMode(0, INPUT_PULLUP);
  digitalWrite(2, LOW); //turn LED off
  rtc.begin(); //Start RTC library, this is where the clock source is initialized

  rtc.setTime(hours, minutes, seconds); //set time
  rtc.setDate(day, month, year); //set date

  rtc.setAlarmTime(00, 00, 10); //set alarm time to go off in 10 seconds

  //following two lines enable alarm, comment both out if you want to do external interrupt
  rtc.enableAlarm(rtc.MATCH_HHMMSS); //set alarm
  rtc.attachInterrupt(alarmMatch); //creates an interrupt that wakes the SAMD21
  [b]attachInterrupt(0, Inter, FALLING);[/b]


void loop() {

  if (matched)
    matched = false;
  digitalWrite(2, HIGH);
  digitalWrite(2, LOW);
  digitalWrite(2, HIGH);
  digitalWrite(2, LOW);

  int alarmSeconds = rtc.getEpoch();
  alarmSeconds += 10;
  rtc.standbyMode();    // Sleep until next alarm match

void alarmMatch() {
  matched = true;

void Inter() {
    Serial1.write("Hello world\n");

Go Up