The ESP8266

Introduction

A few years ago, I came to the conclusion that it made sense to ignore most non-ARM embedded processors. ARM seemed unbiquitous and enjoyed enormous network effects, and so I thought that if anything interesting came out in the non-ARM world one of the many ARM licensees would release somethineg similar without undue delay.

So, when I first heard about Expressif’s ESP8266 and found out that it had Tensilica’s Xtensa core, I didn’t pay it the attention it deserved. Instead I waited for a cheap ARM-equivalent to appear, and dominate the market, but that doesn’t appear to have happened.

So, belatedly, I’ve been playing with the ESP8266, and these are some brief notes on the topic. Much of the information here can actually be found on Wikipedia1, but I didn’t absorb it before I’d spent a while messing around.

Hardware

The basic chip is a 3.3V 32-bit RISC CPU running at 80MHz. It has loads of hardware for networking, including most of the stuff you need for Wi-Fi, and a mixture of the usual interfaces: SPI, I²C, &c. Expressif’s website has a good ESP8266 section2, including a data sheet3.

Expressif also have a useful Github repo.4 which contains esptool.py, a python script for low-level access to the ESP8266 over a serial connection.

Modules

In practice, rather than use the bare chip, it’s easier to use a module which usually adds some flash, a Wi-Fi antenna, and an oscillator. Some modules are need to be incorporated into a larger design, whilst others essentially stand alone, needing nothing more than a USB cable to work.

Many of the basic modules come from AI-Thinker, and many of USB-connected modules use an AI-Thinker module rather than the ESP8266 chip directly.

The list below isn’t exhaustive, but covers the things which I found on a random trawl of eBay and Amazon in mid-2017. You can find a more complete list at e.g. the ESP8266 community wiki5.

Modules without USB

The ESP-01 from AI-Thinker

This is a small PCB with the ESP8266, 512kB of flash (on my boards W25Q40BW6), and a 8-pin DIL header. There’s a PCB antenna, but no shielding can.

The main benefit of this module is that it’s cheap, but the flash is smaller than most other boards which limits the software you can install. Upgrading the flash chip7 isn’t hard, but it’s not worth the time.

The ESP-07 and ESP-12 from AI-Thinker

These are small modules with the ESP8266, some flash, and an antenna. The electronics live in a shielded can, and Wikipedia claim that the ESP-12 is FCC approved.

The differences:

1MB of flash on the ESP-07, 4MB on the ESP-12.

Ceramic antenna with a U.FL connector8 on the ESP-07, PCB antenna on the ESP-12.

The ESP-12 module comes in -E and -F varients: it’s not clear to me how they differ. Some of the modules have an extra side of pins, but I think most of these are used to talk to the flash chip.

Both modules have both pinholes and castellated edges on a 2mm pitch.

Neither module has any mounting holes.

Programming

The lack of any USB support means that you’ll have to connect a serial connection yourself. I pondered building a board to do this, but found that smdking on eBay9 already made such a thing10. Cunningly it uses horizontal pogo-pins to connect to the board.

Against smdking’s advice, I added a bodge wire to get 5V from the USB port. The limited current on USB ports mean that using an external PSU is better.

Olimex MOD-WIFI-ESP8266-DEV

In some ways, this is a bit like the ESP-01 being the ESP8266 and flash on a board with a PCB antenna. No screening can.

However:

it is physically bigger;

it has 2MB of flash rather than 512k;

it brings all the pins to connectors rather than just a few.

So it’s a much more capable board the ESP-01, but I can’t see any reason to buy this over the ESP-12 unless you want the DIL form-factor.

Modules with USB

NodeMCU

NodeMCU11 applies both to a dev. board and some firmware, though here we’ll just consider the hardware.

The NodeMCU hardware is a ESP-12F module on a board, plus a USB serial interface and 5V to 3.3V voltage regulator. The serial interface uses a CP210212USB bridge.

Connection to the board is made via Micro-USB and a 30-pin DIL header with 0.9” spacing. Happily the board has M3 mounting holes in the corners.

Clones of the NodeMCU abound. I bought some LoLin brand boards which are a bit cheaper, somewhat larger, and use a CH340 USB-serial bridge. Size matters here: the DIL pins are 1.2” apart, so it’s not plug-compatible with the official boards.

Wemos D1 mini

Wemos13 make a range of ESP8266 boards, of which the most common one seems to be the D1 mini14.

Functionally, it’s identical to the NodeMCU board, but it’s physically smaller. One downside: no mounting holes.

Programming

The ESP8266 comes with a bootloader, so to flash new firmware all you need is a serial connection. All the usual serial chips have been pressed into use: CH340, CP2102, &c.

To flash the firmware nRST and GPIO0 on the ESP8266 must be driven appropriately15: reset while GPIO0 is low. These lines are often connected to the modem control signals RTS and DTR.

I think this standard started on the NodeMCU, either way it seems sensible to copy their schematic16.

CH340 on the Mac

Some programming software, notably the mongoose OS mos tool has trouble with CH340 based programmers on the Mac. I avoided this by using a spare Linux box instead.

Firmware

The original ESP8266 almost pretended to be a modern modem17: it accepted Hayes style commands18 over the serial port, but connected to Wi-Fi rather than the telephone network.

In 2014, Expressif released an SDK allowing people to replace this, making the ESP8266 a lot more interesting19.

Shortly after this, NodeMCU20, an open-source firmware was released. It allows you to program the ESP8266 in Lua21, potentially speeding development. You can grab all this from Github22.