loading
Internet of Things Class
Enroll
Lesson 3: Hardware Setup
Ask a QuestionOffice Hours

In this lesson, we'll take a closer look at the ESP8266 hardware and the techniques you'll need for creating your own circuits in the rest of the lessons. If you bought a pre-assembled board, you don't absolutely need to know how to solder to complete this class, but a lot opens up to you if you do! Check out the Soldering lesson from Randy's Electronics Class to learn how or brush up on your skills.


Solder Headers

You have a few options when it comes to connecting to your Feather Huzzah board. The connectors we'll attach are called header pins (or just "headers" for short), and they are available in several flavors.

You can purchase the Feather Huzzah and other ESP8266 boards preassembled with male or stacking headers, but if you want terminal blocks or some other way to connect, you'll have to solder them up yourself.

To solder on plain male header pins, first use the board to measure and cut the strips to length, if necessary.

Insert the short end of the pins into the underside of the board and sandwich them into a solderless breadboard to align the pins and clamp them in place while soldering. Solder one pin on each strip to stabilize any wobble, then go back and solder the rest of the pins in place. This same header soldering procedure is handy for lots of other boards and accessories— add it to your toolbox!

For stacking or female headers, use a piece of tape to secure the headers to the top side of the board. Tack solder one pin on each strip. If it's crooked, you can reheat this one pin while realigning the header strip before soldering the remaining pins.

For wires you need to route into an enclosure, or for components you want to disconnect frequently, terminal block headers are a useful choice. If you want your circuit to be super flat, you may opt to attach wires directly to the board and skip headers entirely.

I usually keep a Feather Huzzah board with stacking headers around, just for prototyping. When I want to build a finalized circuit, I might choose lower profile components, but the convenience of easily plugging and unplugging components works fabulously for the prototyping stage of any project.


Pinout Diagram

This chart shows the various functions of the Feather Huzzah ESP8266 board. NC stands for "not connected". This information is consolidated from the (much more detailed) product documentation for the Feather Huzzah ESP8266. Here is a summary of the pins' functions and things to watch out for:

RST - 3.3V reset pin, connect to ground momentarily to reset ESP8266

3.3V pin (500mA peak current, under 250mA recommended to maintain wifi performance)

GND - common ground for logic and power

ADC - analog input (1V max, use a voltage divider if working with a higher voltage signal)

Pin 14/SCK - 3.3V digital GPIO, SPI default SCK pin

Pin 13/MO - 3.3V digital GPIO, SPI default MOSI pin

Pin 12/MI - 3.3V digital GPIO, SPI default MISO pin

(SPI is a protocol for controlling devices though bitbanging, such as LED Backpacks)

RX - receive input to the ESP8266 module (5V compliant, has level shifter)

TX - transmit output from the ESP8266 module (3.3V), avoid using if serial communication is active

CHPD - 3.3V enable pin for ESP8266, connect to ground momentarily to reset ESP8266

BAT pin - positive voltage from lipoly battery jack (if connected)

EN pin - connect to ground to turn off 3.3V regulator (everything on board except lipoly charger)

USB pin - positive voltage from USB port (if connected)

Pin 14 - same as SCK above

Pin 12 - same as MI above

Pin 13 - same as MO above

Pin 15 - 3.3V general purpose input/output (digital GPIO), has pull down resistor built in, should not be high at startup to avoid bootmode

Pin 0 - 3.3V digital GPIO with built-in red LED (set LOW to turn on), no internal pullup resistor, should not be low at startup to avoid bootmode

Pin 16 - 3.3V digital GPIO, connect to RST to use this pin to wake from sleep mode

Pin 2 - 3.3V digital GPIO with built-in blue LED (which is also connected to the wifi antenna), internal pullup resistor connected, should not be low at startup to avoid bootmode

Pin 5/SCL - 3.3V digital GPIO, I2C default SCL pin

Pin 4/ SDA - 3.3V digital GPIO, I2C default SDA pin

(I2C or "eye squared see" or "eye two see" is a protocol for controlling devices though bitbanging, such as LED Backpacks)


Building Circuits

Let's put together a basic circuit that will be useful and relevant to the rest of the lessons. If the solderless breadboard is still a mystery to you, have no fear! First review the introductory lesson in the Arduino class to learn how breadboards work.

As a quick refresher, remember that the breadboard has long busses that run along each edge, and shorter connectors in the center, separated by a bar down the middle.

Insert your Feather Huzzah into your solderless breadboard, straddling the middle bar. Do the same with a small pushbutton. Remember to always disconnect power/USB when making wiring changes.

Next, grab an LED and connect its positive (longer) lead to a hole in the breadboard next to pin marked 13 on your board. Plug the negative (shorter) lead of the LED into the breadboard's ground bus (any hole along the labeled blue line). The button and LED make up the most basic input and output for your first experiments. Since the Feather Huzzah is a 3V device (Arduino Uno is 5V), I chose not to use a resistor with my LED.

Let's add some wires to connect up our LED and pushbutton. First it's important to establish a common ground, so pick up a wire (any color will do but for convention I'm using black) and plug it into any hole along the ground bus and the hole next to the pin marked GND on your Feather Huzzah board.

Connect another wire from the ground bus to one of the legs of the pushbutton.

Lastly, connect a wire from another leg of the pushbutton to pin 4 on your board. We'll be activating this pin's internal pull-up resistor in the code in order to read the button.

Double check your circuit against the circuit diagram, then plug in the USB cable to your computer.

Load up this sample code (copy from below or download this step's attachment and open in Arduino); it's just a basic button-illuminates-LED circuit that will test your wiring and further cement your understanding of the software/hardware workflow.

#define LED_PIN 13
#define BUTTON_PIN 4

// button state
int current = 0;
int last = 0;

void setup() {
  pinMode(LED_PIN, OUTPUT);
  pinMode(BUTTON_PIN, INPUT_PULLUP);
}

void loop() {
  // grab the current state of the button.
  // we have to flip the logic because we are
  // using INPUT_PULLUP.
  if(digitalRead(BUTTON_PIN) == LOW)
    current = 1;
  else
    current = 0;

  // return if the value hasn't changed
  if(current == last)
    return;
 
  digitalWrite(LED_PIN, current);
  
  last = current;
}

Test that once the code is uploaded to your board, pressing the pushbutton lights up the LED. If it doesn't, check this list of common errors:

  • Wire connection missing/incorrect (unplug before making changes)
  • LED connected backwards
  • Code not uploaded successfully
    • Board type incorrect
    • Port not selected/incorrect
    • Board must be in boot mode (automatic on Feather Huzzah and Node MCU, often achieved with a combination of button presses on other boards)

Now you're all set to tackle your first project prototype! Post a celebratory photo of your illuminated circuit in the Class Project module below. Do not proceed until you've got a working pushbutton circuit, as it is the basis for adding internet-connectivity and more complex features later in the class. If you're stuck, look down below for the Ask a Question section!

CLASS PROJECT

Share a photo of your finished project with the class!

Nice work! You've completed the class project