Seeduino XIAO RTC sleep

Hi, Im new to this but trying to learn as I go. I have a problem using rtc.standbyMode(). So I use the following to blink the LED and it works as expected…

#define PIN_LED_13 (13u)
#define PIN_LED PIN_LED_13
#define LED_BUILTIN PIN_LED

#define PIN_LED_RXL (12u)
#define PIN_LED_TXL (11u)
#define PIN_LED2 PIN_LED_RXL
#define PIN_LED3 PIN_LED_TXL
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
pinMode(PIN_LED2, OUTPUT);
pinMode(PIN_LED3, OUTPUT);
}

void loop() {
digitalWrite(LED_BUILTIN, HIGH);
digitalWrite(PIN_LED2, HIGH);
digitalWrite(PIN_LED3, HIGH);
delay(2000);
digitalWrite(LED_BUILTIN, LOW);
digitalWrite(PIN_LED2, LOW);
digitalWrite(PIN_LED3, LOW);
delay(1000);
}

But when I use rtc.standbyMode() to put it to sleep then wake up, the LED turns on after 20sec of sleep but just stays on and wont blink. see below how I do it.

#include <RTCZero.h>

/* Create an rtc object */
RTCZero rtc;

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

const byte day = 17;
const byte month = 11;
const byte year = 15;

#define PIN_LED_13 (13u)
#define PIN_LED PIN_LED_13
#define LED_BUILTIN PIN_LED

#define PIN_LED_RXL (12u)
#define PIN_LED_TXL (11u)
#define PIN_LED2 PIN_LED_RXL
#define PIN_LED3 PIN_LED_TXL

void setup() {
pinMode(LED_BUILTIN, OUTPUT);
pinMode(PIN_LED2, OUTPUT);
pinMode(PIN_LED3, OUTPUT);

delay(5000); //delay so we can see normal current draw

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(17, 00, 20); //set alarm time to go off in 20 seconds
rtc.enableAlarm(rtc.MATCH_HHMMSS); //set alarm
rtc.attachInterrupt(ISR); //creates an interrupt that wakes the SAMD21 which is triggered by a FTC alarm
rtc.standbyMode(); // Sleep until next alarm match
}

void loop()
{
// not used
}

//interrupt service routine (ISR), called when the interrupt is triggered
//executes after MCU wakes up
void ISR()
{
digitalWrite(LED_BUILTIN, HIGH);
digitalWrite(PIN_LED2, HIGH);
digitalWrite(PIN_LED3, HIGH);
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
digitalWrite(PIN_LED2, LOW);
digitalWrite(PIN_LED3, LOW);
delay(1000);
}

Trying to teach myself here so any help is appreciated.

Hi fbb034

Your program just runs once in setup(), basically setup() just for the initialization, your main function should be put in the loop.

Best regards
Fenyi