I'm building a datalogger based on the ItsyBitsy M0 (SAMD21G18 chip). I am logging analogReads from a sensor to the built-in QSPI Flash. I need to log data at ~2hz, so i'm using a 500ms sleep to shut the board off in between datapoints. Using the Adafruit Sleepydog library and Watchdog.sleep(500), the program will run perfectly for 1-2 hours, and then the board will randomly reset. This problem has been discussed here: strange reset on Feather M0 after random minutes · Issue #9 · adafruit/Adafruit_SleepyDog · GitHub, with no solution (I tried the suggested SysTick fix to no avail...it still resets every few minutes to hours). Replacing delay(500) for the sleep(500) works well indefinitely, which is what implicates the sleep code.
As an alternative, I tried to use the Arduino LowPower library's deepSleep() for 500ms. Again, the code logs perfectly for a while (8 hrs 20 min in the first run). However, it then stops logging, though it does not reset like the sleepydog version (i don't know if it crashes somehow or just doesn't wake from a sleep).
These are the only two methods i have found to put the M0 to sleep for less than 1 second. Does anyone have any suggestions for how I could make either of those work reliably (the dataloggers must be deployed for 3+ weeks and run unsupervised), or an alternative that would allow me to reliably sleep the board for 500ms on loop?
Thanks so much for any advice, these forums are an amazing resource for people like me trying to learn to program these things!
Any advice is much appreciated.