Getting Started with the ESP8266: Choosing the Part
If you have been following the Maker scene in the last year or two (especially things related to embedded projects and the Internet of Things) you may have heard about a mysterious WiFi adapter called the ESP8266. Or was it a microcontroller? Whatever it was it didn’t come from a manufacturer you recognised like TI or Atmel, but it was pretty cheap. Actually, it seemed to be an order of magnitude less than anything else! Just ridiculously cheap. If you dug any farther than that you were probably confronted with a bewildering variety of modules, no clear toolchain, and no way to easily move forward. That’s the position I was in until this weekend, when I finally forced myself to sit down and figure out what this ESP thing was all about.
The core of the Espressif Systems’ ESP8266 is an 80MHz (overclockable to 160MHz!) 32 bit Tensilica Xtensa LX106 microcontroller combined with 64 KiB of instruction RAM and 96 KiB of data RAM. The magic is that it also integrates a TCP/IP stack and all of the RF hardware (besides an antenna) required to connect to 802.11 b/g/n WiFi networks. At purchase each part comes with firmware that allows the ESP8266 to be controlled via AT commands, which includes scanning for or hosting WiFi networks and making requests. However there is also an SDK to write native code which runs standalone. This makes it exceptionally easy to integrate WiFi connectivity into other designs or to use it as a standalone microcontroller.
When referred to in the hobbyist community people are almost always thinking of one of the myriad first or third party modules the ESP is available in. These come in a variety of form factors, but nearly all integrate an additional 512KiB or more of SPI flash, a PCB trace antenna or uFL connector, and break out a variable number of pins. Espressif sells around 15 of these (the ESP-01 through ESP-13, with multiple models) with different form factors, mounting styles, and exposed pins. All share the same UART programming interface. And they range from comically inexpensive to merely inexpensive. The simplest module, the ESP-01 can be had for about $7 from a familiar vendor like Adafruit and Sparkfun, but if the user is willing to go a little farther afield and tolerate slower shipping it is easily available for as little as $1.75 from places like Aliexpress!
Likewise Sparkfun, Adafruit, Seeedstudio, and more sell integrated development boards that make it easy to attach and ESP8266 to a breadboard and program it. The most popular option is the NodeMCU board which breaks the bank at about $4.00 shipped (again from Aliexpress).
Let’s talk about the most common modules, the ESP-01, ESP-12, and NodeMCU:
The ESP-01 is the module that started it all. This little guy only breaks out 2 GPIOs, but that doesn’t limit its usefulness as a WiFi interface for another microcontroller (I’m partial to the Cypress CY8CKIT-049 PSOC3 development boards) or even as a simple standalone device. It runs on 3.3v, and if you’re aiming to build a simple internet connected button or light it’s hard to go wrong here.
The ESP-12 series of modules (ESP-12, ESP-12E, ESP-12F, etc) are the heart of most ESP8266 devices. Unlike the ESP-01 which breaks out only 2 GPIOs, the ESP-12 exposes all pins to castellated vias and wraps it all up inside a protective RF can. This is probably the module to use for custom dev boards.
The NodeMCU module (from a company apparently called NodeMCU) wraps the ESP-12 into a feature-filled little dev board. The NodeMCU breaks out all the ESP-12 pins, but also includes a micro USB connector with onboard USB-Serial converter for charging and power, power regulation to 3.3v, 3.3v-5.0v level shifting on IOs, reset and program buttons, and LEDs. Plus everything comes out of breadboard-able 0.1” headers.
NodeMCU is also the name of a firmware distribution for any ESP series module (though it was initially designed for this one). The NodeMCU firmware encapsulates a Lua interpreter which can run saved programs or be used live REPL style over serial. The NodeMCU firmware can be flashed to any ESP8266 device, and makes a good jumping off point for quick prototypes.
If you’re looking for the fastest way to get started with the ESP8266 family, the NodeMCU board is your best choice.
|Part||GPIO||Analog||Programming Interface||Supply||Approximate Cost (Sparkfun)||Approximate Cost (Aliexpress)|
|NodeMCU||9||1||UART via USB||5.0v (USB)||$12.95 ||$4.00|
 From Seeed Studio.
As a companion to their extreme low cost, the ESP8266 family has certain traits which make them somewhat less convenient than a similar WiFi enabled MCU like the Particle Photon to get started with.
- Bare modules have 3.3v supply and logic levels and may be damaged running at 5v.
- No bare module is convenient to use with a breadboard. The ESP-01 does have 0.1” headers, but their arrangement makes it impossible to plug in. Other modules with castellated vias are slightly narrower than 0.1” and need to be broken out before they can be directly plugged into a breadboard.
- The smaller modules (like the ESP-01 and ESP-03) may only have a few exposed GPIOs making them less suited to standalone for tasks more complex than blinking a light or watching a button.
- On all modules the CPU shares time between the user’s application code and the radio stack. If the developer isn’t careful to yield time to the CPU, they can starve the network stack and experience erratic performance.
- To boot the device normally the CPU needs GPIO15, GPIO2, and GPIO0 to be pulled high. Pulling GPIO0 down during reset will enter programming mode. This incantation makes the programming sequence on simple breadboards a little more complex. Many breakout boards include buttons to ground this pin, so the user only needs to press a pair of buttons together to enter programming mode.
An Espressif employee has already revealed information about the next generation of modules, which are particularly exciting. Besides RAM and peripheral selection improvements, it is slated to include a second CPU core and Bluetooth (LE and Classic). On top of that, they plan to further reduce the price of the ESP8266!
In Part 2, I’ll discuss how to connect one of these boards to your development machine, get setup with the tools required, and get some small samples working.