Uploading new firmware through code [Solved]

Hi

Not sure if there is a thread addressing this already, but I couldn’t find one, so decided to start my own. I want to push and hold a button to put the photon in listening mode, or safe mode or basically any other mode than plain running, in order to upload new firmware without access to the reset and mode buttons on the photon itself. Is this at all possible? Reason I ask is because the photon is going to be built into an enclosure or a box, but I still may need to change the firmware, or at least parts of it.

1 Like

You can always use an IO pin, set it as an INPUT and whenever there’s a change, you will call System.enterSafeMode().

It can be made into a :cloud: function as well so when you call the function, the device resets and enter safe mode. This does not require a button but having a physical button makes it (more) reliable and failsafe.

Hi, what do you mean? thanks

There might be times where the internet/cloud connection is down but having an IO pin that is continuously polled in your firmware will ensure that it enters safe mode. :smile:

I mean that having a :cloud: function would eliminate the need for a physical button to trigger safe mode.

1 Like

ok perfect, I see.
Also one advantage of the button is that it covers the case where the user changed their router’s ssid (or its credentials).

question: is there another way of addressing the scenario where a customer/user changes their router’s settings besides either dedicating a pin for this (as described in this thread now) or just telling the user/customer to open the enclosure and hitting the mode/reset buttons?

(sorry @batmanish hope I’m not hijacking your thread)

Another way might be to have the device expose a softAP that the user can connect to and set the new WiFI credentials via WiFi. Some great work has been done to make this possible in firmware v0.5.0 but still requires some user side coding to get this working.

I see some pros and cons with this approach of not using a button. Having a user button reduces any second guessing when the device stops connecting to wifi and the customer forgets that there’s a softAP exposed for updating settings. It is more likely that they go, why isn’t it working compared to them explicitly hitting a button to show intent of updating wifi credentials.

1 Like

awesome, thank you for the details!

If you are using a Photon you can keep all standard GPIOs free and attach the external button to the dedicated SETUP solder pad on the bottom of the board.

2 Likes

This!! This is exactly what I was after! Thank you so much, works like a charm!

Hi, what do you mean by this? I was looking at my photon and couldn’t figure it out.
thanks!

The Photon datasheet shows this pinout diagram

And the SETUP pin 26 refers to this solder pad at the bottom side of the Photon

2 Likes

thank you again!