RTC issue when going to sleep

I'm working on a project that needs to go to a low power state periodically. I'm using the internal RTC of the SAMD21 to keep track of date and time. The code is implemented using the RTCZero library and the Arduino Low Power library. The issue I'm having is that when the USB cable is disconnected, executing the LowPower.sleep for the first time causes the RTC to reset. Is there a workaround for this issue?

USBDevice.detach();
LowPower.sleep(10000);
USBDevice.attach();

Why are you apparently disconnecting and reconnecting the USB either side of a sleep ?

Is the USB cable connected and powered when you use the sleep mode ?

Yes it maybe connected sometimes. It is to save power in case the USB cable is connected.

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