Low Power Sleep how to keep track of time?

I am using the ArduinoLowPower library to put the MKR board into sleep and just recognized, that millis() does not count while in sleep. What other options do I have except an external RTC attachment (suggested in stackoverflow forum)?

The LowPower docs on deep sleep actually say, that the RTC clock is still running while in sleep (here) but I couldn't find a way to access it.

I was also thinking of IDLE mode, but since I am running on Battery, I would like to save as much energy as possible. Could anybody tell me the power differences, no info found.

Any ideas?

Use the built in RTC. Surely there are some tutorials on how to do that, but if not, the processor data sheet has all the details.

Hint: if you have questions about a particular Arduino, it makes some sense to say which one, don't you think?

The datasheet for the SAMD21 suggests that to be true:

The RTC can wake-up the device from Sleep modes using the alarm/compare
wake-up, periodic wake-up, or overflow wake-up mechanisms

You may need to expand this a little. Are you having trouble accessing the RTC (Real Time Counter) to configure and use it.

From the docs you linked to, does:

LowPower.deepSleep(milliseconds);

not work for you?

Works for me on an XIAO SAMD21, very useful it is too.

1 Like

The above works well. But I recognized that the millis() function is not continuing to count during sleep. But now I am using the RTC clock which works well.

Indeed millis() does not run in sleep.

1 Like

My datasheet from a SAMD21 has table 16-4 (Sleep Mode Overview) in section 16.6.2.8 Sleep Mode Controller. That table lists which clocks are running in the various sleep modes.

There's an Atmel app note - "AT11491: Peripheral Power Consumption in Standby Mode for SAM D Devices" that may give you some more detail as well.

Thats going to be specific to the particular Arduino, what it uses for a regulator, USB interface other bits and bobs etc. Unfortunatly all to often board manufacturers seem to keep quite about thier board deep sleep currents.

The SAMD21 itself is capable of very low power RTC deep sleep. Oqn the XIAO, if you remove the green power LED, the deep sleep current is around 5uA.

And if the

LowPower.deepSleep(milliseconds);

Is not quite your thing, you can use the RTC to set the time, then set an alarm to wake it up at some time in future. Deep sleep current is the same as the deepSleep() command.

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