Basics

Let's get the Hacker Boards up and running in Arduino!

Hacker Boards hardware

The Hacker Boards are a simple development platform for WiFi-connected hackathon hardware projects. Here's a list of what's on the board:
  1. ESP8266 WiFi module - This module is the main "brains" of this board. When we're writing code and say we're "programming" the board, we're actually programming this module. This contains the microprocessor that runs the code, a WiFi radio hardware, and has various pins - physical connections - that one can attach various pieces of hardware to (i.e. LEDs or buttons) via the through-holes. There is a small blue light on the module that shows when the ESP8266 is being programmed.
  2. Through-holes - These are holes that are connected to the various pins of the ESP8266. Using header pins, these through-holes allow the ESP8266 to be easily breadboardable.
  3. Header pins - By soldering these into the through-holes, an ESP8266 can be easily plugged into a breadboard.
  4. Blue POWER LED - If this blue LED is on (or whichever LED has POWER written next to it - the colors may be flipped with the next LED), then the board is receiving power. When you plug this board in, this LED should turn on and stay on.
  5. Yellow GPIO 0 LED - GPIO is one of the two types of pins on the ESP8266, and stands for General Purpose Input-Output. Essentially, it can output a logical high voltage (3.3 volts), or a logical low voltage (0 volts, or ground). This LED shows which state GPIO 0 is in. When the ESP8266 boots, this LED should blink momentarily.
  6. RESET button - Pressing this button resets, or essentially restarts, the microcontroller. Very useful if you want to restart your program quickly!
  7. GPIO 0 button -
  8. Pressing this button makes GPIO 0 become a logical high, at 3.3 volts. Don't press the button while trying to turn the LED on
  9. White LEDs - WS2812B These are addressable LEDs that can be programmed to show a variety of colors. Use the Adafruit NeoPixel library to talk to them on GPIO pin 15
  10. CP2104 chip This chip lets your ESP8266 module communicate to your laptop through USB. Use the Serial object on your Arduino to send messages to/from your laptop.
  11. microUSB port This is where you plug in your USB cable so that it can connect to your laptop. You can also power your board through this with a portable battery.
  12. Optional potentiometer This is a dial you can solder onto your board. If you use analogRead(0) in your program, it will tell you how far the dial is turned (0-1023)
  13. Breadboard If you solder header pins onto your board, you can set it on a breadboard. This will allow you to connect other things to it, like sensors, LEDs, and more!
Alright - try plugging in your ESP8266! You should see the yellow GPIO 0 LED flicker, and the blue POWER LED turn on and stay on.

Let's go download drivers!

You're going to want to download and install three things. First, there is the Arduino IDE (which we'll use for writing code and programming the boards). Secondly, a USB driver for the CP2104 - which is a chip on the board that converts USB into serial, which the ESP8266 can understand. Thirdly, a "board package" for the Arduino IDE, which contains all the files the Arduino IDE requires that has support for the ESP8266.

  • You can download the latest copy of the Arduino IDE from the top of the official Arduino download page - choose the right one for your operating system (I used 1.6.7 for this tutorial, but it should work with any Arduino version after 1.6.4, which added support for board packages).
  • You can find the CP2104 USB drivers from the chip's manufacturer, Silicon Labs, on this page - once again, choose the right one for your operating system.
  • Lastly, there's the ESP8266 Board Package for Arduino. We'll be downloading and setting that up in the next section, as part of Arduino.
Arduino Preferences menu on OS X

Go ahead and install the Arduino IDE and the CP2104 drivers, and come back when you're set!

Setting up the ESP8266 Board Package for Arduino

Open up the Arduino IDE. Once open, go to the Preferences window (on OS X: Arduino -> Preferences) and add the text http://arduino.esp8266.com/stable/package_esp8266com_index.json

Boards Manager on OS X
into the "Additional Board Manager URLs" field (which is near the bottom).

Next, open up the Board Manager (on all platforms: Tools -> Board: "Arduino Uno" -> Boards Manager...), and scroll down to the bottom of the list of installed boards. At the bottom, there will be an entry with the title "esp8266 by ESP8266 Community". Click anywhere in that box, select the latest version (2.0.0), and press the 'Install' button. Once the bottom bar says Installation completed!, close the Boards Manager.

Libraries for Examples

There are a few libraries you'll need to get started. The first set are the WiFi libraries. These conveniently come with the Board Package you should have already installed! You can find them in Sketch->Add Library->ESP8266... The one we use for our examples is ESP8266WiFi.

The next library you need is the Adafruit NeoPixel library. You use this library to interact with the addressable LEDs. Download the library from this link as a .ZIP file. To add it to the Arduino IDE, go to Sketch->Include Library->Add .ZIP Library. If you're on a Mac, you'll have to re-zip the folder by right-clicking and clicking on Compress "...".

After that, you should install an Arduino library for parsing JSON. We use it for one of our demos. You can find it at this link. Install it the same way you installed the NeoPixel library.

The 'Hello World' of Hardware

Just as a program that outputs "Hello World" is typically the first program that a person writes when learning programming for the first time, a program that blinks an LED is typically the first program written for hardware. To run a program that blinks the small LED next to the Power LED on the Hacker Boards, in Arduino, download the code here . It's a modified version of the standard Arduino Blink example, which lives in File->Examples->Examples->01.Basics->Blink. Just change line 20 from pinMode(13, OUTPUT); to pinMode(0, OUTPUT);, since the small LED on the board is on pin 0.

Make sure to set the "reset method" in the Tools menu (Tools -> Reset:Method) to nodemcu instead of cu.

Addressable LEDs

Addressable LEDs are special LEDs that you can chain together and program individually. You can tell them what color to be, and how bright to be! These boards have two chained together, and are both controlled with GPIO 15.

To add them to your project, go to Sketch->Include Library->Adafruit NeoPixel. This will add the correct header file to your project. You will then need to create an instance of the object that will interact with the leds with the line Adafruit_NeoPixel name = Adafruit_NeoPixel(NUM LEDS, IO PIN, NEO_GRB + NEO_KHZ800); "name" is what you want to name your object (usually "leds" is good), NUM_LEDS is the number of addressable LEDs you have chained (always 2 for this board), IO pin is the control pin for the LEDs (always 15 for this board), and the last line configures the LEDs (that's always the option you want for this board).

To change the color of your pixels, use leds.setPixelColor(#,r,g,b);. "#" is the index of your LED (always 0 or 1 for this board), and r/g/b are the color values for each LED. 255/255/255 is bright white, 0/0/0 is off. You also have the ability to configure the brightness of all of the LEDs with leds.setBrightness(#);. "#" is a value 0-255, where 0 is off and 255 is blindingly bright.

After you configure your LEDs, you need to add leds.show();. This tells the microcontroller to update the LEDs all at once.

There's an demo project at this link . It makes your LEDs blink random colors!