Introduction: Getting Started With the WF32!

About: I build robots out of boxes! I love teaching what I've learned and seeing people add their own ideas to what they've learned. Nothing excites me more than seeing a student really take an idea and run with it!

Hey! This tutorial is out of date! Since I created this Instructable, the server example code has been updated to use a better method of manipulating the DP32 via wifi. Check out joshwoldstad's tutorial for using the updated code!


Welcome, new users, to the WF32!

The WF32 is a powerful little board from Digilent, with an SD card reader and a WiFi card, not to mention plenty of digital and analog input/output pins. However WiFi can be a little intimidating to new users (it was to me) but I'd like to help you start your own WiFi projects.

This tutorial will help you use some example code that turns the WF32 into an HTTP server and then modify it to send simple instructions to the WF32 to blink an LED.

Because of that, this project could also be called "WiFi Blinky".

Step 1: Knowledge Base

This tutorial assumes you already have some passing familiarity with chipKIT boards like the WF32. I assume you already have MPIDE and all the libraries for the board installed on your computer, and that you know how to make and upload programs to the board. If you do not, I would suggest you go to the Digilent Learn site, click on the "Browse Modules" link, and go through the "Getting Started with Microcontrollers" module before starting this one.

If you need to install the libraries, go to the WF32's product page. At the very bottom of the page is a set of download links with useful things like the WF32's reference manual and schematics. The third link in this list contains the libraries you'll need, so click it to download that file. When you un-zip the file, you'll find a ReadMe.txt in the main folder that will have instructions on how to install libraries.

(In the fourth download link you'll find the HTTP server example we'll need for this project, so you might as well grab it now too.)

Step 2: What You'll Need

For this project you'll need the following hardware:

  • WF32
  • WiFi router (you can use your home's wireless internet if you have it)
  • Micro SD card and reader

As well as the HTTP server example code. NOTE: The HTTP server code hosted on the WF32's product page has been updated since (and because) I posted this Instructable! The server code I've included here is the old version, compatible with my tutorial. The new code includes a better method of manipulating the WF32 over wifi than my tutorial uses. To try that out, you should check out joshwoldstad's updated WF32 tutorial!

(You'll also need basic things like MPIDE and a mini USB cable, but we assume you already know that.)

(D-Link router image taken from

(Micro SD card image taken from

Step 3: Open the Example Code

Open up the "WebServer" file inside of your unzipped "HTTPSrv" file. Don't worry about all the other files inside here for now, just open up "WebServer.pde". That will open up an MPIDE window with tabs for all the other files in the project! Isn't that handy?

Step 4: Before We Begin

The first thing I'm going to do is show you how to get the HTTP server example code working, but the example code already comes with a file that shows you how to do that.

Open up the "Content" folder. Open the file called "SrvSetup.htm" with your preferred web browser.

This file has detailed instructions on how to set up your server using the WF32, but they're a little too in depth so I'll provide much briefer instructions next.

Step 5: Get the Code to Work

Go back to MPIDE. Open the tab for HTTPServerConfig.h. Scroll down to where it says "SET THESE VALUES FOR YOUR WIFI AP".

The variable "szSsid" contains the name of your network (also known as the SSID). Change that from "chipKIT" to your network's name.

The set of #define statements below that set up your WF32 for different types of wireless network security. The most common type of security (and the most secure) is WPA2.

If you're using WPA2

uncomment the line:


and comment all the others out.

The variable "szPassPhrase" contains your WiFi network's password. Change that from "Digilent" to your network's password.

Check picture 3 in this step to see what that will look like once you're done.

If you're using a network with no security

Comment out all five #define statements.

Step 6: Copy Content Onto Your SD Card

Plug your SD card into your computer. It should be formatted to FAT32 by default. If you're a Windows user, you may have formatted it to NTFS at some point. If so, Radioshack has a tutorial on how you can reformat it.

Copy the contents of the "Content" folder onto the main folder of your SD card. Make sure to only copy the contents of the folder, and not the folder itself, because if any of the files are hidden inside folders, your WF32 won't be able to find them when it needs them.

Step 7: Plug It in and Run!

Eject your SD card (with all the files on it) and plug it into your WF32. Then go back to MPIDE and upload the code to your board.

Once the code is done uploading, open up the serial monitor using the button in the upper-right corner of the MPIDE window. You'll see some text come up like in the first picture in this step, which tells you a lot about what the board is doing. We won't get into this part in too much detail, but we will be using a part of it later.

You're going to have to wait about a minute to find out if your board has connected to the network correctly or not. If it connects correctly, it'll look like the second picture in this step. If not, it'll look like the third.

If your WF32 doesn't connect, you may have mistyped either your network name or password in the code. Either that, or you picked the wrong type of network when you were uncommenting #define statments in the previous step.

Step 8: Visit Your WF32's Website!

At the bottom of the messages you get from the serial monitor, you'll find your WF32's IP address. Copy that number into a web-browser (leave off the ":80" at the end) and hit enter to be taken to your WF32's website!

Click some links and see how the URL changes. All of the sites starting with your WF32's IP are files on your SD card, but try typing in:


You should get a page that looks like the third picture in this step. That's a page you won't find anywhere on your SD card. This is a dynamically generated page, meaning that instead of looking for a file on the SD card, the WF32 executes code that creates a page from scratch. This is important because we can use it to get the WF32 to do a lot more than just host a website.

Step 9: HTMLBlink.cpp

Our first step is to create the C++ code that will define how our new dynamically generated page will work.

Go back to MPIDE. Click the arrow on the far right and add a tab. Title it "HTMLBlink.cpp".

Open up the tab "HTMLSample.cpp", select all the code there and copy it into "HTMLBlink.cpp".

Now do a search for every instance of the word "sample" and replace it with the word "blink". Make sure you capitalize "blink" every time the word "sample" was capitalized, and don't capitalize where it's not. The easiest way to do this is uncheck the box marked "Ignore Case" in the search window, and do two searches, one for "sample" and another for "Sample".

Step 10: Matching Strings, Compose Functions, and Adding HTML Pages

Go back to the "WebServer" tab.

Scroll down to the section labeled "HTTP URL Matching Strings" (it'll be on line 121). Add the line

static const char szHTMLBlink[]        = "GET /Blink ";

That string is how our WF32 will know we want access to our blink page when we type "<IP>/Blink" into our browser.

Right below there, under the line:

GCMD::ACTION ComposeHTMLSamplePage(CLIENTINFO * pClientInfo);


GCMD::ACTION ComposeHTMLBlinkPage(CLIENTINFO * pClientInfo);

This is the definition of our blink page's compose function. This function has already been written in our HTMLBlink.cpp file, so we don't need to write it ourselves.

At this point, your code should look like the first picture in this step.

Now scroll down a little to the Setup section, where you'll find the line:

AddHTMLPage(szHTMLSample,      ComposeHTMLSamplePage);

Below that, you'll add the line:

AddHTMLPage(szHTMLBlink,      ComposeHTMLBlinkPage);

That will add our blink page to the list of dynamically generated HTML pages.

Your code should look like the second picture in this step.

Step 11: Test /Blink

Now, upload your new code, wait for the WF32 to reconnect, and try going to <IP>/Blink. If everything has been done correctly, you should see the above picture.

Step 12: Modify Blink

Now that we've got our blink page up and running, let's modify it to use our GPIO pins to blink an on-board LED.

Open up the "HTMLBlink.cpp" tab again and scroll down to the section labeled "HTML Strings". You'll find a variable called "szBlink" that contains the test string that actually is our blink HTML page. Remove the line "This is a simple HTML blink page that was dynamically rendered." and replace it with simply "Blink".

Below this section, make a new section by copying the following code:

/* Variables */ /************************************************************************/ // This will keep track of how many times the page has been visited static uint32_t szHitCount = 0;

Your code should look like the first picture in this step.

This creates a variable that we'll use to count how many time the pages has been visited.

Now, scroll down to the ComposeHTMLBlinkPage function (line 110). Right after the line:

Serial.println("Blink Page Detected");

copy the following code:

szHitCount ++;

if (szHitCount % 2)
	digitalWrite(PIN_LED2, HIGH);
	digitalWrite(PIN_LED2, LOW);

Your code should look like the second picture in this step.

This code will count how many time people have visited this page, and on every odd visit, it'll turn the LED on. Every even visit turns it off.

Now, lastly, we'll need to go back to the WebServer tab, into the setup section, and set our LED's pin mode to output (it should look like the third picture in this step).

Upload the new code to your board and test it out! Every time you re-load your blink page, your LED should switch states! How cool is that?

This is, of course, just the beginning. By using dynamically generated pages as commands like this, you could do all sorts of things. This is, of course, a somewhat restricting method, but for beginners, like me, it's a good jumping off point for your own projects.

Good luck!