No time for flashing when using System.sleep

Hey, here’s a question that has been bugging me for a couple of days now.

I am using “System.sleep” to get my Photon to sleep between temperature reading operations on a DHT22. All works fine, and the rig has been running for about three days now on the same battery pack.

However, when trying to flash something new to it, I am unable to do so, since it only wakes up to make the reading, and publish it, and then goes back to sleep again. Which then gives me not enough time to flash it.

What is the recommended procedure here? I know I can factory reset it and flash again, but this loses all my settings, and here just has to be a better way of doing that.

Thanks in advance

If you have easy physical access to the unit, the easiest way that I know is to set a sleep / no sleep switch by monitoring one of the spare pins in your project. If the pin is ‘HIGH’, use a delay instead of sleep. If the pin is ‘LOW’, then sleep. If you do this, you don’t even have to reboot the unit, just move a wire or flick a switch.
I know that the Particle team is working on some sort of queue, where you can upload your changes and they get applied the next time that your system contacts Particle, but if you are sleeping for any long period of time, developing your code would still be a pain, That is why the ‘program/run’ switch makes sense to me.

If you have local access to the device, a lot of people put some kind of switch/jumper that you read (using a digital in pin) and use that state to modify the behaviour of loop(), so it does not sleep and leaves itself open to OTA updates.

Of course this doesn’t help much for remote/deployed devices.

The Particle team recognize the use case you describe, and I believe are planning to roll out queued events like OTA updates - so that the cloud will queue up the firmware update until the device checks in. I don’t have an ETA for this, I’m sure others will chime in with more details and when you can expect to see this deployed.

You dont need to factory reset, you can use safemode instead.

Hold reset and setup, let reset go and keep holding setup for a second or so, not too long cause the same option is used for dfu and factory reset.

Safemode will remain online to accept firmware.

In the future it should be possible to queue firmwares, so that the device will download it when waking.