Spark core push button to connect to the internet?

how can i program the spark core with push button, that when pushed it will automatically connect to the internet? (local internet)

Your question isn’t really clear to me. Could you elaborate a bit further? In order to make the Spark work (without disabling the cloud) you would have to have it connected to the internet already.
Of would you like to toggle the wifi function by pressing a button? For that you could use the digitalRead function, and then toggle a state in your code which in turn toggles the wifi (check the docs for the relevant code on the wifi).
There is however no code to get you to ‘magically’ connect to a unknown network, without already having entered the credentials.

I hope this somehow helps. Good luck!

I think i understand what you are saying, do you mean start in a wifi off mode, then when the button is pressed turn the wifi on and connect to the router?

If so it is possible,

#include "spark_disable_wlan.h"
#include "spark_disable_cloud.h"

will boot the core with wifi and cloud off,

then have something to do


when the button is pressed.

1 Like

yup you got it right but the thing is, can it be that when pressed it will automatically connect with the desired network? can i also put the network name and password in the code, so that when pressed the core will first look if it has connection and then if it doesnt have then no connection.

If a known network is within range, the Core will indeed, automatically connect to it, if wifi is enabled.
You can toggle the wifi with the relevant code, as mentioned above. I can imagine something as a button interrupt, which toggles a state, which is then tested in a for loop. Could be even easier though, I’m not sure.

To hardcode the credentials, you would have to make a local build (as far as I’m aware). There are some threads about this topic on the forum. You should be able to find them using search.

I don’t think putting the SSID and password in code for connecting has been implemented yet, or even if it will? not to say it cant be done with local builds

it remembers the SSID and password and will automagicly connect with the WiFi.on() call to the last network (possibly up to 8?? i dont know how you add extras without deleting the last??)

Its something i wanted when i first got the core, i thought it would be great to plug in the usb, enter a menu and put in the SSID and password and have it connect, but the spark/TI solution was even better, do it wireless no plugging in required.

there is a thread here which may have some more useful info:

There isn’t a nice wrapper for it yet, but it’s here and here: