AUTONOMO RTCZero wake-up/sleep cycles

Hi guys, i have read the forums and examples included with gabriel’s RTCZero but i can’t get a simple loop timer to work with my autonomo, how do i make it wake up, do something and then sleep for 10 mins in a continuous loop?

Thank you in advance for your help!

The RTCZero library configures the alarm to generate an interrupt at a configured time. This interrupt wakes the board from sleep mode.

The __WFI() call in this example is the call for the board to enter sleep mode and Wait For Interrupt.

You can specify the specific time and date for the alarm to be generated. Additionally, by using the alarm mask you can specify what components of the time and date to match and what parts to ignore.

For example, by using the MATCH_YYMMDDHHMMSS mask, the alarm interrupt will only be generated when all components of the date and time (year, month, day, hour, minutes, seconds) match. Whereas the MATCH_SS mask will ignore everything except for the seconds value, using this mask will generate an interrupt every minute when the seconds value of the clock matches that of the alarm.

This makes it easy to create regular interrupts with the intervals of once per minute, per hour, per day, per month and per year. Creating a regular interrupt for other periods is a bit more complicated. Effectively, you will have to reschedule the alarm each sleep/wake cycle.

If you want a 10-minute sleep/wake cycle, I would recommend using the MATCH_MMSS mask (match minutes and seconds). Then reschedule the alarm minutes value every cycle with something like:

rtc.setAlarmMinutes((rtc.getAlarmMinutes() + 10) % 60)

Thanks for the reply!
What confuses me regarding this example is WHERE to put the rtc.setAlarmMinutes… at loop or at setup???
the RTC object runs in paralell to the program flow?


In your use case you will need to put the call to rtc.setAlarmMinutes() in Loop, as you need to reschedule the alarm every cycle.

The RTC is a hardware component of the SAMD21 chip, the library allows you to interface with that component to configure it.

Gabriel, that exampled when trying to compile gives the next error
"Arduino: 1.8.1 (Windows 10), Board: "SODAQ Autonomo" sketch_may02a:7: error: 'H24' was not declared in this scope rtc.begin(H24);"

the only way to make it compile is to use rtc.begin(); instead

any ideas?

Yeah, sorry, the example is a bit out of date.

The choice of 12 or 24hr mode was removed a while back, the library now defaults to 24hr mode.

Hi Gabriel, i kind of made it work … but with some problems. Do you think you can take a look at this?