Micro Explorers

Introducing The ESP8266

Tim Blythman

Issue 2, August 2017

This tiny WiFi chip packs a massive punch. Easily programmed and barely the size of a USB plug. Let's take a closer look.

If you’ve been working with microcontrollers, especially Arduinos, or have ever been interested in adding WiFi to a project, you might have heard of the ESP8266 IC and its various modules. It’s a product of the Espressif company, and was not widely known until it was noticed by the maker community. Through the community’s efforts and Espressif’s release of their SDK, the ESP8266 has turned into one of the go-to choices for makers who wish to add a WiFi microcontroller to their projects.


The ESP8266 is a microcontroller with b/g/n WiFi and a full TCP/IP stack, meaning that most of the hard work in making and communicating over a WiFi connection is done by the microcontroller. The ESP8266 needs external flash (for program storage) to operate, and to fit this bill, the ESP8285 (a microcontroller with in-built flash) and a vast range of modules have been developed. It’s these modules that most makers will be familiar with, as they also remove the need to solder surface mount devices. In fact, many modules are fitted with 0.1” spaced headers, allowing for use on breadboards, even though they are typically not much bigger than a coin.

They do come in a few different shapes and sizes though, the image on this page showing two different styles of ESP8266 commonly available.


The ESP8266 is not just about the WiFi, and its specs look like they put an Arduino UNO to shame. But, that’s not to say that you should throw the UNO out - because the ESP8266 needs to spend time handling WiFi connections, and it is less suited to timing critical applications including PWM. There are a few restrictions on use of the I/O pins – for example, some are shared with the SPI bus that accessed the program flash storage, so cannot be used without great care.


I first started out using ESP8266 modules with an ESP-01 module, and connected it to my computer via a USB-serial converter. A lot of modules will come loaded with a variant of the “AT Command” firmware, meaning you can issue commands directly to the microcontroller - with functions such as “scan for WiFi networks” and “connect to server”. You can perform the microcontroller equivalent of opening a web page in about half a dozen commands. This setup is a great way to test and get to know how the ESP8266 works.

The next step will be to program a microcontroller to run these commands and autonomously access the WiFi network. An understanding of how network protocols work is really handy for this; for example, for emulating the function of a webserver or web client.

Another step beyond using the AT commands is to program the ESP8266 as a microcontroller in its own right. In this project, I’m using the Arduino-ESP8266 add-on, which offers a WiFi library with similar features to the Ethernet library. There are also implementations of languages such as NodeMCU, Lua and even BASIC.

To program the ESP8266 on its own, you’ll need a Serial-USB converter, or preferably, one of the many boards that incorporate the ESP8266, a USB-Serial converter, and usually a breadboard friendly pinout including breakouts for IO pins. As with many ICs these days, the ESP8266 is rated at 3.3V, so these boards should also include a 5V-3.3V converter as well.


You will have to have Arduino IDE version 1.6.4 or later, so that you can use the Boards Manager feature to install the add-on. It’s as simple as opening the Boards Manager (Tools>Board>Boards Manager…) and searching for ‘esp8266’, and installing the entry by ESP8266 Community. If your search doesn’t show this entry, you might need to go into File>Preferences, and add this URL:


to the Additional Boards Manager URLs near the bottom of the Settings tab.

After this, you should see a group of boards appear under ESP8266 in the Tools>Board menu. I found the “Generic ESP8266 Module” seemed to work for most cases where I wasn’t sure which board to use. You’ll also find a heap of example sketches under the File>Examples>ESP8266 menu. The CheckFlashConfig sketch can help you fine-tune these settings.


Earlier, I mentioned you shouldn’t throw away your UNO yet, and after being comfortable with official Arduino boards, you might find there’s a few bumps on the way to using these boards. For a start, some boards do not use an obvious pin numbering scheme. There seems to be a mismatch between the Arduino IDE pin numbers and the ESP8266 pin numbers. For some of the boards, there are defines, such that “D4” is actually mapped to the logical pin reference in the Arduino sketch. In other words, if the pin number doesn’t seem to be working, try prefixing a “D” to the number. Fortunately, everything seems to be mapped correctly on the XC4614 WiFi Shield from Jaycar that we tested.

Generally, you may find compiling and uploading takes longer than other boards, and the sketches always compiled to at least 200kB, presumably incorporating some base libraries.

If you are using the bare modules or some of the boards, you might also find that you need to use some tricks to correctly put it into “bootloader” mode to accept sketch uploads. To program the XC4614 WiFi Shield from Jaycar (as a standalone board) with an USB-Serial converter, I had to hold down the “KEY” button, press and release the “RST” button, then release the “KEY” button. On boards that don’t have buttons (such as the ESP-01), it’s necessary to use two jumper wires to provide the correct sequence of inputs to activate the “bootloader” mode.

I also found that I was getting "function not defined in this scope" errors where the same sketch would compile successfully for other boards, but not for ESP8266 based boards. In this case, it appears to be a bug in the ESP8266 board profile, which is referenced here.

The quick fix for this is to add function prototypes to the top (before the function is used) of the sketch, and an example of this is given in the Modem Restarter project.


If you feel like you know your regular Arduino boards quite well, then you should have no trouble getting the ESP8266 up and going. The Arduino implementation isn’t quite as polished, but as with the other boards, there is a community of people on the forums who are always working to make it better.

We also use the ESP8266 in our WiFi modem restarter project elsewhere in this issue! For this project, we use Jaycar’s XC4464 USB-serial converter and XC4614 WiFi Shield. This shield breaks out all the IOs, has convenient RST and KEY buttons and includes 5V-3.3V converters for power and the serial port, providing some handly methods to get it all going.