Global Sources
EE Times-Asia
Stay in touch with EE Times Asia
EE Times-Asia > RF/Microwave

DiY IoT: Let's talk WiFi

Posted: 16 Oct 2015 ?? ?Print Version ?Bookmark and Share

Keywords:Internet of Things? IoT? microcontrollers? Texas Instruments? CC3200?

A few words about security: WiFi, like any wireless communication, holds a vast potential for security risks. This was understood very early into the adoption of wireless technology, and a few standard solutions arose. The first (and weakest) is WEP encryption with a pre-shared key, and it gives some very basic security that is rarely used nowadays. WPA and WPA2 with technology-standard TKIP or AES encryptions are the standard choices. Stronger, enterprise level solutions exist but are rarely usedeven by enterprises.

Now, after this introduction, let us talk about applications. Together, we will make an application that posts sensor information to an internet site that aggregates the information and plots it as pretty graphs. The solution will work in three distinct phases:

Provisioning phase: The board will function as an access point and a web server. The user will be able to connect to the access point, open the web browser, and see a web page where he needs to provide network and web credentials for a household access point and the data aggregation site.

Setup phase: The board will terminate the web server, connect to the data aggregation website, and set up the plots.

Sensor Machine phase: The board will run in periodic cycles, reading sensor data and posting it to the web

This project is a little big to fit into one post, so today we will work on the first part.

I will make all the sources available on GitHub.

The library we will be using most heavily today is called . (Notice the capital W and capital F). It brings many of the low level functions we will be using together with an exported object walled WiFi. However, there is one little bug in the library itself that prevents me from using it as-is, so I have added a fix to my local version and I suggest you do the same. The bug is about a variable inside the library called "role"; it is not being updated properly and causes the board to get stuck in AP mode without the ability to switch back to normal client mode. I have tried to limit my intervention in the library as much as possible, so the impact is minimal.

My local updated version of WiFi.cpp is also available on the GitHub. To use it, put it into your "/Applications/" folder.

To start an AP mode, we will use a function called "beginNetwork()" that can be called with an SSID and password or just with an SSID. Since it is the first stage, we want the network to be open and to give the user unrestricted access for setup purposes. Theoretically, we should be able to do WiFi.beginNetwork("CC3200Logger"),

but from my experiments, it seems there is another little bug; the network it comes up as password-protected, but the problem is that I don't know the password because I didn't create one. I came up with a simple solution. Before calling beginNetwork(), I explicitly specify that this is an open (unprotected) network:

unsigned char val = SL_SEC_TYPE_OPEN;
sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SECURITY_TYPE, 1, (unsigned char *)&val);

This seems to solve this problem, and the access point now lets you connect without a password.

The next step is to enable the server on port 80, and since the class to do this is called WiFiServer, we will declare it as:

WiFiServer server(80);

To put it into action inside the loop (as it needs to accept connections):

WiFiClient client = server.available();

Now our solution is ready for the next stepwe need to be able to present some sort of "enter user/password" web page and later parse the response and act accordingly.

The little page I made for our needs right now is:

Notice the hidden "e" element; it is there just to simplify the parsing of the response.

?First Page?Previous Page 1???2???3?Next Page?Last Page

Article Comments - DiY IoT: Let's talk WiFi
*? You can enter [0] more charecters.
*Verify code:


Visit Asia Webinars to learn about the latest in technology and get practical design tips.

Back to Top