Exit safe mode with button press on WKP

Is it possible to exit safe mode with a button press to either the WKP pin or any other pin?

I’d like to be able to put my device into safe mode with a button press via the System.enterSafeMode(); command. This is relatively easy to implement in my app.

However, if this is done by accident, I’d like to be able to exit safe mode with the same button. Is this possible? Right now, the button is connected to WKP, but I can move this to any other pin.

As a tangential question – can you instruct the device from the cloud to exit safe mode?

Safe Mode means, none of your code is running anymore, so the easiest way out of Safe Mode via the reset button or pin.

Via the cloud might be possible by triggering a “dummy” OTA update which isn’t intended to stick but pushes you out of SM.

So if someone wants to expose just one button on their product, and use safe mode, how might you go about that?

I can see how resetting via cloud would work, but it seems like this may be unreliable, especially if your device doesn’t have internet for some reason.

Hi @hwestbrook,

So you want a button that toggles safe mode?

What if you incorporated an ATtiny85 chip into your product?

You could make the ATtiny read the button and either trigger the WKP pin on the Photon to enable safe mode, or trigger the RESET pin on the Photon to reboot the Photon and exit safe mode.

This tutorial shows you how to program the ATtiny85 using an Arduino.

You’d not even need an extra chip, if you had the button wired to WKP and RST while the RST connection is controled via transistor(s) and another pin, which will be pulled HIGH from your code to “cut/overrule” the button-RST connection while Safe Mode does not pull HIGH end hence the button would cause a reset.

Ah, OK, good idea! Thanks!