SAMD21 (Arduino Zero) Wake up from alarm or external power

Hi everyone.

In my current setup i have a SAM D21 chip which is connected to a power supply and a battery. It will switch to the battery when the power supply drops. However, i want a led to blink after 24 hours of running on a battery. Is it possible to set an alarm using the RTCZero library and use the lowpower deepsleep() and attachInterruptWakeup() functions to put the chip to sleep or wake it up early?

ok so while posting this i thought of a solution thanks to the following topic i found: Low Power Sleep how to keep track of time?

What i am going to do is i am going to use lowpower.deepsleep(86400000); as 246060*1000 = 86,400,000 ms and then i will connect a pin in such a way that it is connected to the power supply in a safe manner. This way it will notice when the supply stops, well, supplying and then switch to deepsleep. then the same pin is attached to lowpower. attachInterruptWakeup(pin, pinWakeup, CHANGE); to see if power comes back and run the function: pinWakeup if thats the case, maybe keep the led on. if the power is not back in 24 hours then the following will happen. another interrupt is called, but this time using lowpower.attachinterruptWakeup(RTC_ALARM_WAKEUP, alarmWakeup, CHANGE); this will run the function alarmWakeup which will let the led flash until the power supply is on again. Hope this helps someone else too, if there any questions leave them below. i'll see if i can answer them.

NOTE: the datatype for the time is a uint32_t aka an unsigned 32 bit integer with a max value of 4,294,967,295 ms aka 49.7 hours. so anything longer than that needs a different solution.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.