Let's say you have a device you built that uses something like an Arduino with a Wifi shield. The intent of this device is to connect to your wifi network, and then connect to the internet and do something (use your imagination).
If the device was so simple that it did not have any buttons or a screen on it, how would one initially configure it to connect to a particular WiFi network?
(Obviously directly inputting the wifi network parameters into the source code for your project is out of the question).
I have been thinking about this lately and wasn't sure what the best approach was.
Yesterday something happened that got me thinking. I purchased a WiFi enabled Honeywell Thermostat for our house. It connects to your WiFi network so you can control the thermostat using your phone from anywhere in the world.
The method used to connect the thermostat to the wifi was interesting though. When you first hooked up the thermostat, it would create it's own wifi network/server called "Thermostat_EKDD94" or something. You use your phone or laptop to connect to this network. Then visit 192.168.1.1 in the browser, in which you see a list of available wifi networks to connect to. You pick the network, input the password, and then the thermostat disconnects you and connects to the network you picked. At this point, the thermostat's own wifi network/server goes away for good (unless you do a hard reset on the thermostat at a later time).
And just like that, your thermostat is connected to a wifi network of your choosing, all without having to actually touch the device. It was a very interesting approach. Is this something that is possible with an Arduino? Can it act like a server and then client? Maybe at the same time?
Any thoughts to this approach or if there is a better approach?
Best Answer
Any WiFi module that supports ad-hoc mode should be able to do this. I've used the WiFly module before, and I know it has this capability. Note that the module can only be in ad-hoc or client mode at any given time; not both at once.
You can use that module directly with your Arduino (assuming Uno or compatible footprint) via this shield. There is also a standalone shield that might be more space-saving. Of course, other modules are available that are up to the task but these are the ones to come mind.
Here is how I would set up this specifically. In response to your comment, I've modified the approach to fix the problem of what happens if the WiFi association fails.
http://[WiFly address]:80/status
.Special considerations:
* Interesting side note:
You might be wondering how the module can scan for networks while in ad-hoc mode. According to the manual:
If your requirements allowed a separate user interface (perhaps an application on your laptop), you could have used this feature to your advantage and avoided crafting an HTTP server altogether. The application could have connected to the WiFly's ad-hoc network, opened a Telnet session, and then automated the Telnet session to configure the module.
Alternate approach
If cost is not an issue, you could use two WiFly modules - one to provide a constant ad-hoc network and the other to act as the WiFi client.