ArduinoCore-stm32l0 icon indicating copy to clipboard operation
ArduinoCore-stm32l0 copied to clipboard

Is it possible to wake from deepsleep using RTC alarm?

Open bjg1968 opened this issue 4 years ago • 1 comments

I want to be able to wake from deepsleep using the RTC alarm. I've tried the following, but still dead asleep. I can get the alarm event to occur, but as soon as I put it in deep sleep, it never occurs again. Am I doing something wrong or is this not possible? Thanks.

` #include <RTC.h> #include <STM32L0.h>

void alarmMatch( void ) { digitalWrite( 13, !digitalRead( 13 ) ); // toggle LED STM32L0.deepsleep(); }

void setup() { digitalWrite( 13, HIGH ); pinMode( 13, OUTPUT );

RTC.setTime(12, 52, 00); RTC.setDate(24, 11, 21);

RTC.setAlarmTime( 0, 0, 20 ); RTC.enableAlarm( RTC.MATCH_SS );

RTC.attachInterrupt( alarmMatch ); // also tried RTC.attachInterruptWakeup( alarmMatch ); }

void loop() { // do nothing here } `

bjg1968 avatar Nov 24 '21 19:11 bjg1968

The STM32L0.deepsleep() needs to be in loop(). And in the alarm callback you need a STM32L0.wakeup().

GrumpyOldPizza avatar Nov 25 '21 23:11 GrumpyOldPizza