Electron restarting after sleep

Hi there,

I have an Election that sleeps for anywhere between 5 minutes and 12 hours.
It is set to wake up upon signal dropping from the pin, or at the end of its cycle. When it reaches the end of it’s sleep cycle, it uploads.
My problem is when it wakes from sleep for anything longer than 2 hours (whether by pin input or at the end of it’s sleep cycle), it either restarts itself or fails to upload.
The code I am using is;

System.sleep(pulseInput, FALLING, SLEEP_NETWORK_STANDBY, sleepFor);

Is there a limit to how long the device can sleep?

Thanks in advance for your help.

SLEEP_NETWORK_STANDBY can only keep the connection open for a limited time - depending on your cellular provider.
With a Particle SIM you’d need to wake at least once every 23 minutes to keep the cloud connection open and once every few hours to keep the cellular connection active.

If you intend to sleep longer, you should make sure that you allow enough time for a full reconnect cycle which can take up to 5 minutes in normal situations and in bad radio situations you might need more than one try to get a connection.
Your code needs to allow for that.


Thank you. Would it be beneficial to add; Cellular.connect() as the first command on wake up to ensure it connects properly?

If you want Particle cloud connection, you’d want Particle.connect() and if your code needs an active connection I’d also put a waitFor() statement before the first statement that requires the connection.

Thank you.
I have done that and it has worked successfully.

The only problem I have now, is it still restarts itself when sleep is interrupted by the FALLING pin.
Complete system reset, but only if the device has been asleep for more than 2 hours.

Any ideas?