# Programmatically entering safe mode

**URL:** <https://community.particle.io/t/programmatically-entering-safe-mode/15172>\
**Category:** Firmware\
**Created:** [September 6, 2015, 11:29pm UTC](https://community.particle.io/t/programmatically-entering-safe-mode/15172 "2015-09-06T23:29:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![evancharlton](https://avatars.discourse-cdn.com/v4/letter/e/f07891/32.png) [@evancharlton](https://community.particle.io/u/evancharlton)\
**Post date:** [September 6, 2015, 11:29pm UTC](https://community.particle.io/t/programmatically-entering-safe-mode/15172/1 "2015-09-06T23:29:35Z")

</div>

Hey folks!

Safe mode on Photon is totally awesome – thank you for that!

However, I’m looking for a way to programmatically put the device into safe mode. I see that there’s System.factoryReset(), but that’s sort of a nuclear approach. I’m hoping for a not-yet-documented System.safeMode() method. Or maybe some magic that I can perform on the RESET pin to kick the system into safe mode.

Thanks!

---

<div class="post-metadata">

**Author:** ![mdma](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/mdma/32/1924_2.png) [@mdma](https://community.particle.io/u/mdma)\
**Post date:** [September 7, 2015, 10:43am UTC](https://community.particle.io/t/programmatically-entering-safe-mode/15172/2 "2015-09-07T10:43:49Z")

</div>

Hey @evancharlton! There’s currently no API in firmware to force a boot to safe mode, but it’s definitely something we want to support. I’ll look into adding this before the 0.4.5 release. 😄

---

<div class="post-metadata">

**Author:** ![evancharlton](https://avatars.discourse-cdn.com/v4/letter/e/f07891/32.png) [@evancharlton](https://community.particle.io/u/evancharlton)\
**Post date:** [September 9, 2015, 2:45pm UTC](https://community.particle.io/t/programmatically-entering-safe-mode/15172/3 "2015-09-09T14:45:34Z")

</div>

Great, thanks!

Something on the reset pin would be awesome, too. For example, the [Sparkfun Pro Micro](https://www.sparkfun.com/products/12640) has a feature where if you connect the reset pin to ground, it’ll reset (duh). If you do it again within 750ms, it’ll go into the bootloader for 8 seconds. (You can read more about it [here](https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide) – search for “Reset to Bootloader”)

Something like that would be fantastic for Photon, so that it could be externally reset to safe mode if it’s e.g. immediately crashing in `setup()`.

---

<div class="post-metadata">

**Author:** ![mdma](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/mdma/32/1924_2.png) [@mdma](https://community.particle.io/u/mdma)\
**Post date:** [September 9, 2015, 4:03pm UTC](https://community.particle.io/t/programmatically-entering-safe-mode/15172/4 "2015-09-09T16:03:30Z")

</div>

I’m not sure if we have any control over the reset pin behavior. @BDub might know otherwise.

---

<div class="post-metadata">

**Author:** ![jrm](https://avatars.discourse-cdn.com/v4/letter/j/3be4f8/32.png) [@jrm](https://community.particle.io/u/jrm)\
**Post date:** [July 28, 2017, 12:51am UTC](https://community.particle.io/t/programmatically-entering-safe-mode/15172/5 "2017-07-28T00:51:15Z")

</div>

Hello,

Is this something that has been implemented? I’m developing on electron device and I’ve come to face on rare occasion bugs in my code that would make the device reset after a few seconds. The problem is of course on my side. However, when it occurs there is no way to remotely recover as there is not enough time between crash to flash OTA. I would like to have a reboot counter stored in flash. And when the device boot up it will check how many restart it has done in a given period and it would force restart in Safe Mode if it pass a given threshold.

Therefore, I very interested to know if the discussion in this thread had result in any implementation of such feature? I’ve not seen it the documentation.

tks.

---

<div class="post-metadata">

**Author:** ![cermak](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/cermak/32/14174_2.png) [@cermak](https://community.particle.io/u/cermak)\
**Post date:** [July 28, 2017, 5:58am UTC](https://community.particle.io/t/programmatically-entering-safe-mode/15172/6 "2017-07-28T05:58:16Z")

</div>

@jrm - Have you tried this?

[https://docs.particle.io/reference/firmware/electron/#entersafemode-](https://docs.particle.io/reference/firmware/electron/#entersafemode-)

---

<div class="post-metadata">

**Author:** ![jrm](https://avatars.discourse-cdn.com/v4/letter/j/3be4f8/32.png) [@jrm](https://community.particle.io/u/jrm)\
**Post date:** [July 28, 2017, 8:24am UTC](https://community.particle.io/t/programmatically-entering-safe-mode/15172/7 "2017-07-28T08:24:23Z")

</div>

… my bad. I didn’t see this. tks for the reply though.
