February 18, 2017

The ESP8266 - working with an ESP-12 module

This is not the best way to get started with the ESP8266. You would be better served to purchase a NodeMCU board (and ditch Lua immediately). The cons of the ESP-12 are: If you buy a NodeMCU board of some sort, you get all of the above, so you can just plug it in using a USB cable and get to work.

On the other hand, there can be some projects where a bare ESP-12 module is exactly what you want, in particular a battery powered project. The advantages are:

The Diagram Above

The nice ESP-12 diagram above is one of Alberto Piganti's excellent graphics for device pinouts. More are discussed in this article:

How to do it

First you will need to provide 3.3 volt power. There are any number of regulators to take 5 volts down to regulated 3.3 volts. I bought a bunch of tiny little circuit boards on AliExpress that do this.

Second you will need some kind of USB to serial chip. There are a myriad of possibilities. I am using an Adafruit FTDI friend. Be sure whatever you use is in 3.3 volt mode.

If you want to work on a breadboard, you will need some kind of transition board to take the signals from the 2mm spacing to the 0.1 inch spacing. This are readily available from the sellers in China, and you may want to just purchase your ESP-12 with the transition board included.

For basic work (like trying a blink demo) you need to connect to 6 pins:

Boot loader

I use a jumper wire to connect GPIO-0 to ground, hit reset and I am running the bootloader. Once the bootloader starts running, you can release GPIO-0. Or you can leave GPIO0 grounded during the whole flashing process and then remove it and hit reset to run your application.

Of course the bootloader runs every time you hit reset, but it looks at GPIO0 on startup (along with GPIO2 and GPIO15). If it is low, it goes into boot mode. Otherwise it jumps to your application code. Note that this means that you are wise to avoid all three of these pins in your application.

So what I do with my ESP-12 is to connect a jumper wire from GPIO-0 to ground. The other pins are OK left alone (in my case anyway). Then I tap my reset wire against ground briefly and voila -- I am running the boot loader. I confirm this using:

esptool -p /dev/ttyUSB1 read_mac
MAC: 18:fe:34:07:85:99

esptool -p /dev/ttyUSB1 flash_id
Manufacturer: e0
Device: 4016
For some reason reading the flash_id takes me out of the bootloader and starts running my application.


There is an on-board LED connected to GPIO2 that you can use for a blink demo. This apparently has no conflict with the state of GPIO2 to launch the bootloader.


The plain vanilla ESP-12 has only 16 pins, 8 on each side. The ESP-12E adds 6 more on the bottom edge (for 22 total). The ESP-12F has the same pinout as the "E", but an improved antenna.


First here are two diagrams provided just to show the pinout for one of these. Note that one of the old ESP-12 will not have the pins on the bottom. These diagrams show the unit viewed from the top.

Everyone seems to have their own ideas about how to label the pins on the bottom.

And here is the schematic for the ESP-12F. Note that the ESP-12E and ESP-12F are said to be identical except for the antenna (which is better on the ESP-12F).

Some notes: