Preventing Particle Electron from getting stuck / hanging breathing cyan

I would like to gather sensor data, publish, go to sleep, repeat. Currently I repeat this cycle every 10 minutes and go to sleep using standby stop mode to save data and avoid having to reestablish a connection each time. My system works fine for anywhere from 0-10 hours, but I always seem to run into problems. The led pattern usually goes from breathing cyan to off, publishing data right before going into stop mode, which is what I want. But sometimes the Particle will breath cyan, and just stay breathing cyan - no data published, and doesn’t go into back stop mode. I can’t let this happen, as it will drain too much battery life. I tried including the watchdog application, but I still ran into the same problem. I understand that connection won’t always be great, so for those cases I would like my system to continue gathering data, but just store it on my SD card and not publish.

Long story short, I want my system to fail safely. Run, publish data, and go to sleep whenever there is a cloud connection. If there is no cloud connection, run and store the data on the SD card, then go back to sleep. I can’t have my system hanging. Here is my code:

https://go.particle.io/shared_apps/5c4c1b9fa48b8fa3fe001071

Does anyone have any suggestions? Any help would be very appreciated

Oh and I noticed this code seems to use a lot of data. That’s why I used standby stop mode rather than deep sleep. Another option I’m considering is publishing my location less frequently. If you have any suggestions for lowering my data consumption please let me know as well.

You need a an external hardware watchdog. Deploying devices in the field, you will be very sorry to leave it out. Search this forum for “external watchdog”.

For serious applications, I think it is that one really major thing, that is sadly missing on particle.io devices.