This week I’m combining two previous projects using the range sensor and wifi modules. This is a distance logger which can be queried via web. Once a button is pressed, the networking stack is started and the webserver is started. The distance module starts recording when anyone gets closer than 50cm. A simple webserver can be queried to get the timestamps and distances.
This projects allows me to refactor the WiFi code into a helper much like my previous helper for the SimpleDisplayHelper and JoystickHelper. The goal is to have a single helper class to handle all the WiFi work for us. This should enable DHCP and connect to the specified network. Finally, it should return the IP address for use in a webserver.
This full solution can be found on my Gadgeteer GitHub repository.
The direct link to the WiFi helper:
Setup of the project is show here:
WiFiRS21Helper usage is very easy. The initalization parameters require the wifi_rs21 object, your SSID and network password. The you simply start the server. Once started, the helper will return the found ipaddres.
WiFiRS21Helper helper = new WiFiRS21Helper(wifi_RS21, "YOURSSID", "YOURPASSWORD"); helper.StartWiFiServer(); string ipAddress = helper.IpAddress;