Uploading Code

Arduino code

Make sure to use Arduino IDE 1.6.4 or higher and follow this tutorial to install the ESP8266 board packages.

Download the code from github by clicking Download ZIP. Uncompress the file and copy the folder to your Arduino sketchbook folder.

Attach the Huzzah ESP8266 to your computer using an FTDI cable. Since it's possible to connect the FTDI cable backwards, make sure to line up the black wire on the FTDI cable to the GND pin on the 6-pin connector. The Huzzah will get power from the FTDI cable, you don't have to have the microUSB plugged in.

Once that is done, open the sketch and select: 

Tools → Board → Adafruit HUZZAH ESP8266

CPU Frequency → 80 MHz

Upload Speed → 115200

Port → select the USB port with the FTDI cable

Make sure the code compiles properly. All of the relevant libraries should be included.

For more information on using the Huzzah ESP8266 module with the Arduino IDE, follow this tutorial.

 

Modifying the Code

You'll need to make some modifications to the code to make it work properly on your WiFi network.

Download: file
#define WIFISSID "YOUR_WIFI_SSID"
#define PASSWORD "YOUR_WIFI_PASSWORD"

Replace YOUR_WIFI_SSID with the name of your WiFi network and PASSWORD with your WiFi password. Keep the quotation marks!

Download: file
#define FORECASTAPIKEY "YOUR_FORECAST_API_KEY"

Replace YOUR_FORECAST_API_KEY with the API key you received when you signed up with DarkSky.net. Keep the quotation marks!

Download: file
#define DOMAINNAME "YOUR_DOMAIN_NAME"

Replace YOUR_DOMAIN_NAME with the domain name hosting the PHP script, e.g. adafruit.com. Keep the quotation marks!

In WeatherClient.cpp feel free to alter the URL path to reflect the location of your PHP script on the web. 

It's a good idea to test the PHP script at this point by pointing your web browser to: http://YOUR_DOMAIN_NAME/weather.php?apiKey=APIKEY&lat=LATITUDE&lon=LONGITUDE&units=UNITS making the appropriate substitutions for APIKEY, LATITUDE, LONGITUDE and UNITS.

Download: file
// New York City
#define LATITUDE 40.69
#define LONGITUDE -73.99

This longitude and latitude are for New York City- feel free to change them to get the weather for your location in the world.  NASA has a good tool for finding your longitude and latitude.

Uploading the Code

Attach the Huzzah to your computer using an FTDI cable, making sure to plug it in the right way. When you're ready to upload the code, put the Huzzah module into bootloader mode. You'll have to do this before each upload. There is no timeout for bootload mode, so you don't have to rush!

  1. Hold down the GPIO0 button, the red LED will be lit
  2. While holding down GPIO0, click the RESET button
  3. When you release the RESET button, the red LED will be lit dimly, this means its ready to bootload

This is what a successful upload will look like:

It can be difficult to access the buttons once the module is in the enclosure! The best way I've found is to manipulate the two buttons with two pairs of tweezers.

Debugging

Use the Arduino IDE Serial Monitor at 115200 baud to check for error messages. The device should connects to WiFi and download the webpage immediately, and then do this again every ten minutes.

If the Huzzah connects to the WiFi network and webpage correctly, the window should look something like this:

Make sure the URL matches the actual location of your PHP script. You can test it by pasting it into a web browser.

If the code is uploaded correctly, you should see the display showing the weather for "Now", "Today" and "Tomorrow".

This guide was first published on Sep 29, 2015. It was last updated on Sep 29, 2015. This page (Uploading Code) was last updated on Apr 23, 2019.