How to remove sketch from Photon?

I am experimenting with System.sleep and made a foolish mistake. I put my photon to sleep right after it starts but I specified the sleep value in milliseconds. So, now my photo will sleep for 1000 days instead of 1 day. And, I can’t upload the fixed code because it goes to sleep right after it starts.

I was wondering how I can recover from this.

I did a factory reset. Then went to the Tinker app to reclaim my device. As soon as I reclaimed it, it went to sleep again. So, I am guessing that a factory reset doesn’t really do a complete factory reset.

Thanks for any and all help. :slight_smile: Eric.

Safe-mode to the rescue. :sunglasses:

2 Likes

I had a similar problem with OTA programming. I learned my lesson. Ever since then, whenever I use ‘sleep’ I use it in an ‘if’ statement, and use a spare pin as a control line that I can jumper to high to avoid going to sleep.
Basically something in the form of “if pinX != HIGH then sleep (xxxx)”

1 Like

Thanks. I was able to upload the corrected sketch. :slight_smile:

@Awake, that is a good idea. I am going to add that to my code. :smile:

This was definitely necessary on the core, since going through factory restore all the time took quite a bit of effort with reconfiguring wifi creds on each restore.

On the Photon with safe mode, you don’t have to do this anymore. Just a quick reboot to safe mode and the device will come back on the cloud (even if your application firmware was crashy.)

2 Likes

@mdma, I looked at the page and for whatever reason, I started with dfu utility section and totally missed the safe mode.