Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to wake from deepsleep using RTC alarm? #196

Open
bjg1968 opened this issue Nov 24, 2021 · 1 comment
Open

Is it possible to wake from deepsleep using RTC alarm? #196

bjg1968 opened this issue Nov 24, 2021 · 1 comment

Comments

@bjg1968
Copy link

bjg1968 commented Nov 24, 2021

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
}
`

@GrumpyOldPizza
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants