Using Photons at remote locations: How to connect WiFi without me being there


Tried again. With the example (blinky) I’ve got breathing cyan and the blue led flashing. If I mod the example by adding


in setup() then it goes into listening mode, and all I get is the hello file.


If the example refers to the blinky example, then that is exactly how it’s meant to be.
In order to get the SoftAP HTTP page delivered when connecting to, then you need to flash the code that impements all of the code shown here

This contains the web page definition and the logic to deliver it on request.
Without that, you’ll be back to the default hello response.

BTW, which two examples were you refering to in the previous post


peekay123 and RWB both posted example code in this thread. Thats what i’m trying to get running, Reference to ‘blinky’ is that is what RWB put in his example, thats what I’m currently messing with (not the original blinky). I’ve tried the exact code in the link you posted too - no joy.


What system version have you got on your device and what version are you targeting in Web IDE?
Can you flash a simple blinky example without SYSTEM_THREAD(ENABLED) and see if that sticks?
When it does, reflash RWB’s original unaltered sample (since this is what I’ve just tried with my own Photon and SoftAP page shows as expected).
Let it run normal breathing cyan for a few seconds and then put into Listening Mode by holding down SETUP till RGB LED blinks blue.
What happens with the D7 LED before and during Listening Mode?


How do I find the system version on the device?
Target version is 0.5.3, which is the same as i’ve used on all my other development.

BTW - had teraterm running monitoring the serial debug and got
"handling page /generate_204"
show up, so the soft_AP code must have been triggered.

Oh, and your assistance is greatly appreciated :smile:


I see!
Maybe this is something your browser does. Instead of just requesting ’ /index’ which the SoftAP would expect it requests generate_204 to get some meta info of the device - interesting!
But still, when I explicitly request generate_204 I don’t get the hello response either :confused:

What happens when you directly request


Ah - that works.

So it is the browser doing something odd when i ask for

I guess the next trick is to spit that out on the debug channel to see whats going on.

this is the debug output when it works:

handling page /generate_204
handling page /index.html
handling page /style.css
handling page /rsa-utils/jsbn_1.js
handling page /rsa-utils/jsbn_2.js
handling page /rsa-utils/prng4.js
handling page /rsa-utils/rng.js
handling page /rsa-utils/rsa.js
handling page /script.js


So perhaps the trick is to make page “/generate_204” to redirect to “/index”?
I’m guessing here - zero experience with this stuff.

but i’d have thought this:

if (strcmp(url,"/index")==0) {
            Serial.println("sending redirect");
            Header h("Location: /index.html\r\n");
            cb(cbArg, 0, 301, "text/plain", &h);

is supposed to do that.


Yup, if you add an or condition there that checks for /generate_204 then this should work.

Good to know that for the future :+1:

Can you report back whether that worked and how exactly, then I can add this to the documented sample the prevent others from falling into the same trap?


I added this:

if (strcmp(url,"/generate_204")==0) {
        Serial.println("sending redirect");
        Header h("Location: /index.html\r\n");
        cb(cbArg, 0, 301, "text/plain", &h);

and it works.

Though I had a devil of a time getting chrome to stop adding stuff to the end of, after all the testing. Damn autocomplete.

A more thorough approach would be to compare to a list of legit pages, and default to “/index.html” if there’s no match.

Thanks again, you’ve been of immense help. :+1:


That’s a sensible suggestion, I’ll try to come up with something.


This may be relevant to this particular issue:
Chrome network portal detection


I’d like to recap the above and someone(s) please validate the steps. Much appreciated!!

Today we flash our Protons before they are sent to the field and the setup button is accessible (just in case) and the WiFi for the device is setup in the field. Today it is me setting the ID for each one by hand using the ticker app (it’s way beyond our users to download and use) and we were going to embark on writing a two mobile apps that just had the purpose of setting the WiFi credentials on the device. So this is good news!

Does this make sense?:
1-We flash the device before it leaves with our firmware
2-User gets device. It should be in listen mode already but just to be sure we will have a key sequence (we have 5 buttons) which can put the device in listen mode.
3-The user looks for the SoftAP SSID and connects via laptop or smartphone (via WiFi)
4-User goes to where that page (foo.html) is served up by our firmware (based on @peekay123’s code (as amended)).
5-Once they choose the SSID and type in the password, device’s firmware exits listen mode and reboots

Sounds too easy to be true. Did I miss anything? Where can I find the latest firmware snippet to use?

(Would be ideal to include a simple page in the system firmware image but that’s a different story…)

Many thanks,


Nope, that’s just it - but there are some mobile devices that just refuse to connect to an AP if that doesn’t also hook it up to the internet (which SoftAP won’t be able to).

The docs about SoftAP with a boilerplate sample is found here

If you only want to setup WiFi, you won’t need your own foo.html since the default index.html in that sample does just that.
You can even alter the HTML of that page to fit your design needs and just navigating to will be enough as the default /index path hit by browsers will be forwarded to /index.html.


Where is the DONATE button!?!? Seriously, two years later and this code just worked great for me! Thank you @peekay123!


Can this also page also be used to set the host name?


The host name can be set via



Are you running your project inside the script of the softAP?
My goal is to have the photon run the AP portion and then once connected to the wifi to run the final firmware automatically without having to flash it manually. any ideas?