[SOLVED] Time.now() after waking up from System.sleep(SLEEP_MODE_DEEP, sleepForSeconds) on Electron

I have some code which, if there’s nothing much going on, puts the Electron into deep sleep for a time by calling System.sleep(SLEEP_MODE_DEEP, sleepForSeconds). When the Electron board awakes from this function, in setup(), I check the time and, if it’s in the last century, I connect to the network to establish time.

My problem is that when I call Time.now() in setup() it always returns 1970. Surely a wake-up from deep sleep should have no effect on the RTC (as it was clearly there to wake me up just microseconds earlier)? I really don’t want to have to register with the network each time I return from System.sleep(SLEEP_MODE_DEEP, sleepForSeconds), otherwise I’m burning the power I saved by switching the modem off in the first place. I am aware that I have the option of keeping the modem on by calling System.sleep(WKP, RISING, sleepForSeconds, SLEEP_NETWORK_STANDBY) instead, but that burns 5 mA that I would rather save.

I’m running in semi-automatic mode.

1 Like

@BDub any recommendations here?

Apologies, I tried to reply to this by e-mail but it didn’t get through. This turns out to NOT be a problem for Particle, I had some code that was zeroing the RTC which I didn’t think was in play, but it was. All my fault, not your problem, apologies for the disturbance.

1 Like