Introduction: Software Setup

Hang on to your keyboard and mouse, this part might get bumpy! Follow along closely as we configure and upload your first DIY wifi-connected software. In this lesson, we'll install the ESP8266 boards packages inside your Arduino software, install a device driver for the board's communications chip, and upload an Arduino sketch that connects to your home wireless network. Then you'll be all set to go tinker your heart out. Don't fret if these mandatory setup tasks get you down; the good news is that once you've completed the steps and tests in this lesson, you won't have to do them again (unless you're setting up a new computer).

To get started, you'll need:

Computer running Arduino software (free, available for Mac/Windows/Linux, unfortunately the web editor does not support the ESP8266 at this time)

Adding ESP8266 Board Support to the Arduino Software

Download and install the latest version of the Arduino software on your computer, if you haven't already. Open up the Arduino application and navigate to the menu item Arduino->Preferences.

By default, the Arduino application supports chips used in official Arduino boards, but not the ESP8266. These boards can be programmed "out of the box" because the Arduino application already knows about each one and its properties. One cool thing about Arduino is that you can add support for other boards, and all you have to do is tell Arduino where to discover their properties. The first step of that process is providing a URL to the Additional Boards Manager. In the text box near the bottom of the Preferences window, paste in exactly this text:

http://arduino.esp8266.com/stable/package_esp8266com_index.json

If the box was not blank when you opened the Preferences window, you may have some other boards already installed. If that's the case, append the text box's contents with the above URL, using a comma to separate multiple URLs.

Click OK to close the Preferences window. Now our Arduino application knows where to find info about ESP8266 boards in general.

To get specific, navigate to the menu item Tools-> Board:(board name)-> Boards Manager. Allow a moment for the boards manager to download its index, then start typing "ESP8266" into the search bar.

When you see "esp8266 by ESP8266 Community," you can stop typing in the search and click "Install" to get the latest boards package installed inside your Arduino application.

The Feather Huzzah has a handy USB communications chip on board, but it requires a free driver to be installed to function properly. Without it, your board would not show up in the list of available serial devices. Head to the SiLabs page and download/install the driver that matches your operating system (Mac/Windows/Linux available).

Got all that? Great, let's test it out in the next step!

Connect to Wifi

It's time to put some code on your board! Open up a fresh Arduino sketch (File->New) and delete its default contents. Copy this block of code and paste it into the empty sketch:

You may recognize this as the very first sketch you ever put on your first Arduino. Indeed we are saying "Hello, world!" once more, this time by blinking the Feather Huzzah's onboard LED (connected to pin 0).

Port should match your serial device (COMx on Windows, /dev/cu.SLAB_USBtoUART on Mac/Linux), which will only appear while plugged in

Programmer: USBtinyISP

To program your board with the blink sketch, click the Upload button (round button in upper left with arrow icon). The button will turn yellow and the status bar text at the bottom of the window will update you on what's happening. Use the slider bar to adjust the size of the black debugging console below the status bar, and see updates listed as the application compiles your code and uploads it to your board.

This process will seem slower than you're used to when compared to other Arduino compatible boards. Watch the status dots and patiently confirm the text "Done Uploading" appears in the status bar. If get an error message instead, read it and try to figure out what the problem is (wrong port selected, board not plugged in, typo in code). If your board or port isn't appearing in the menus, try these troubleshooting tips and do not proceed until all the software setup steps are complete:

Under the menu Arduino -> Preferences, are there any stray characters or errors in your external boards URL?

Can you see the ESP8266 boards package in the boards manager?

If you are using a Feather Huzzah, did you successfully finish installing the SiLabs driver?

If you are using another board, say with an FTDI programming cable, did you look up any other required installation/setup steps? (Some boards require a combination of button presses to enter bootloader mode.)

Is your USB cable data+power, or power only?

Try to assess and troubleshoot, but reach out for help (with screenshots or pasted error message text) in the Q&A section below if you get stuck!

If all goes well, the red LED on your Feather Huzzah should be blinking. If you're using a different board, your LED may be connected to a different pin or not exist at all. The code would still upload successfully but may not cause the desired result (so look up your board or just continue for now). The next sketch you'll upload will get your board connected to the wifi network.

The next code example comes with the ESP8266 boards package and so is already available in your Arduino software. Access it by navigating to File -> Examples -> ESP8266WiFi -> WifiClientBasic. Alternatively, you can download the file attached to the end of this step and open it with your Arduino software. However if you don't see the example sketches in your software's menu, you are probably also missing the necessary library files to compile it— go back to the software setup step and double check you've installed the necessary boards package.

// We start by connecting to a WiFi network
WiFiMulti.addAP("SSID", "passpasspass");

Edit the variables describing the wireless network name(s) and password(s) ("SSID" and "passpasspass"). If your network has no password, leave the password argument empty ("") but do not omit it. Save the sketch and upload it to your board.

Click the button in the upper right of your Arduino window to launch the Serial Monitor, and select 115200 as the baud rate. Press the reset button on your Feather Huzzah to start its program from the beginning, and watch the wireless connection info appear in the Serial Monitor.

You should see a successful connection message followed by the IP address your device has been assigned. If you don't, double check your wifi credentials for typos and try again. If connected, you'll then see a message: "Trying to connect to 192.168.1.1"

Since 192.168.1.1 is a local network location that may or may not exist, the connection most likely fails.

Update the host variable to any site you like, such as "google.com" just to test your connection. Upload the new sketch to your board and open the Serial Monitor to see the different output. Congratulations, your board just talked to the Internet! We'll dive deeper into the code examples in the sample project lessons.

Install Extra Code Libraries

Now that you've got the basic ESP8266 setup working, let's install some additional Arduino libraries that will be used for later lessons. In your Arduino software, navigate to Sketch-> Include Library -> Manage Libraries..., then search for and install the latest versions of the following libraries:

Sign Up for (Free) Cloud Services

To complete the lessons in this class, you will need to create free accounts on two cloud service websites: Adafruit IO and IFTTT (If This Then That). Adafruit IO is a cloud data service that allows you to set up data streams called feeds to collect information coming from your DIY electronics projects. You can visualize and act on these feeds within Adafruit IO, or expand its function by linking it with IFTTT. IFTTT is a site that aggregates and provides an interface for a multitude of applications, and as such is called an API Gateway.

Head to io.adafruit.com and click "Sign In" then "Sign Up" to create an account.

You should use strong, unique passwords. You may be asked to confirm your email address.

I highly recommend enabling two-factor authentication on your IFTTT account, as you will most likely want to link it to your other personal accounts such as Twitter, Instagram, Fitbit, etc. Keep your accounts safe from hackers and spambots! You will also need to link your Adafruit and IFTTT accounts, which you can do through either site. While you're at it, install the IFTTT app, if you've got an iOS or Android device.

Now that your software is configured, let's dig further into the hardware with the next lesson.