Hackaday Dictionary: The ESP8266

In August of 2014, something new started showing up in the markets of Shenzhen, the hi-tech area of China where the majority of the world’s electronics components are made. This is the ESP8266, a WiFi SoC (System on a Chip) that can connect to 802.11b/g/n networks on the 2.4GHz band. It can be addressed with SPI or a serial connection, and has an AT command set that makes it behave rather like an old-style modem. Basically, it has everything you would need to connect a device to a WiFi network, with the ESP8266 chip itself handling the complicated business of finding, joining and transmitting/receiving over a WiFi network.

That’s nothing particularly new in itself: WiFi connection devices like the TI CC3000 have been around for longer, and do much the same thing. The difference was the price. While the TI solution costs about $10 if you buy several thousand of them, the ESP8266 costs less than $7 for an individual board that can plug straight into an Arduino or similar. Buy the chip in bulk, and you can get it for less than $2.

The ESP8266 is more than just a WiFi dongle, though: it is a fully fledged computer in itself, with a megabyte of flash memory and a 32-bit processor that uses a RISC architecture. This can run applications, turning the ESP8266 into a standalone module that can collect and send data over the Internet. And it can do this while drawing a reasonably low amount of power: while receiving data, it typically uses just 60mA, and sending data over an 802.11n connection uses just 145mA. That means you can drive it from a small battery or other small power source, and it will keep running for a long time.

It wasn’t an easy ship to write applications for in the early days, though: it was poorly documented and required a dedicated toolchain to work with. This made it more of a challenge than many hackers were comfortable with.  That changed earlier this year, though, when the Arduino IDE (Integrated Development Environment) was ported to the chip. This meant that you could use the much easier to write Arduino functions and libraries to write code for the chip, bringing it within reach of even the most casual hacker.

Why Is the ESP8266 Important?

The ESP8266 almost achieves the holy trifecta of electronics: cheap, powerful and easy to work with. Before this, if you wanted to add a wireless connection to a project, you had to use more power-hungry devices like USB WiFi dongles, or squish everything into a serial connection and use a wireless serial link. Either way added to the complexity of the project: you either needed a system that supported USB and had WiFI OS support, or you had to put up with the limitations of wireless serial links, which typically offer very limited bandwidth.

ESP8266 Decapped
A decapped ESP8266, with area of interest marked by Reddit user swimmerdude. The big area on the right is memory.

The advent of WiFi SoCs removed these limitations because the SoC did the heavy lifting, and WiFi offered much more bandwidth. And the ESP8266 did this all at a very low cost: do some digging on eBay and you can get an ESP8266 board for less than $2. So, it is no surprise that we are starting to see the ESP8266 showing up in commercial products.

How Can I Use the ESP8266?

With the popularity of the ESP8266 for adding WiFi to projects, it is no surprise that there are a lot of options for trying it out. On the hardware side, ESP8266 development boards are available from a number of places, including Seeedstudio, Sparkfun and Olimex. Adafruit also has a nice ESP8266 board that breaks out all of the signals for easy breadboard use, and adds a 3.3V output, so it can drive an external device. It is also FCC approved, which is important if you are looking to sell or use the devices you build commercially. Some users have also been building their own development boards, which add features such as LCD displays and buttons.

The Adafruit Huzzah ESP8266 dev board

On the software side, the easiest way to get into the ESP8266 is to use the Arduino compatible mode. This involves loading custom firmware that turns the chip into a mid-range Arduino board, which makes for much easier programming. The people behind this project have produced a list of supported ESP8266 boards: buying one of these will make the installation process easier, as they have noted which data lines in the Arduino SDK correspond to the physical pins on the board. These boards also provide easy access to the reset lines that you have to use to install the Arduino compatible firmware.

This does include some limitations, though: it is rather complicated to upload new sketches over WiFi, and you can’t produce multiple PWM signals, which would make controlling multiple devices difficult. To get access to the full capabilities of the ESP8266, you’ll need to go to the source, and use the SDK that the manufacturers offer. [cnlohr] published an in-depth guide here on Hackaday for bare-metal programming the ESP8266 which was mentioned earlier. Espressif also offer a pretty good getting started guide that covers creating a virtual Linux machine and connecting this to their chips.

The third option is to flash NodeMCU to the ESP8266 module. This turns it into a Lua interpreter. Scripting can be done in real-time to prototype your program, then flashed to the EEPROM to make your program persistent and remove the need for a serial connection.

Beginners will be comfortable with both the Arduino and NodeMCU approaches, but experienced users should be able to wade straight in and start writing code for this cheap, powerful and fairly easy to use chip.

40 thoughts on “Hackaday Dictionary: The ESP8266

  1. ESP8266 is a great module.
    I suggest you this also great application: Fishino.
    Fishino is an Arduino compatible platform with WiFi, RTC and SD card, ALL in ONE.
    But Fishino uses a modified version of ESP8266 module. The firmware inside the wifi module is modified to comunicate with ATmega328 using SPI. This guarantees a communication speed higher than the native serial communication.
    More info about this project are available on
    http://www.open-electronics.org/fishino-arduino-become-wireless/
    http://fishino.it/en/

        1. If you get the Teensy 3.1 and a normal 32kHz watch crystal you can use the Teensy’s built-in RTC function.

          As for the SD card interface: does it use the ATmega328’s SPI bus? If so, then you would be sharing that bandwidth with between the SD card and the ESP8266. The Teensy 3.1 has multiple hardware SPI busses, so it would actually offer better speed, not to mention its faster clock frequency, which also results in faster SPI communication.

          I’m not sure what an SD card interface would cost or how that would compare with the Fishino, though.

          1. Well, in a non-multitasking environment, sharing an SPI bus is not a concern, IMHO. Atmega328’s SPI bus has an 8 MHz speed, which is not enormous but some 80x the speed of normal ESP8266 using serial port.
            Even considering the overhead of SPI procotol you’ve a great speed enhancement.
            Of course, we’re speaking about an arduino-like board, not a linux one.
            IMHO it should be compared to Arduino + WiFi shield + RTC module + an external 3.3v regulator. Which are together by far more expensive. Of course, if you get a 4$ UNO clone + 3$ ESP module + 2$ SD card module + 2$ RTC module + 1-2$ 3.3v regulator you spend some 13$, but then you’ve to add level shifters, wiring and you get low WiFi performances over serial interface. I see the price quite fair for an all-in board.

    1. You are right – it does not support ad-hoc. But it’s not useless for mash as it supports a mode when it runs as AP and client at the same time – prividing much better mash capabilities than ad-hoc.

      1. Is that so? Can one MCU connect to many others (all working in AP+client mode)?

        Take for example B.A.T.M.A.N. routing protocol. It works in a ad-hoc networks and relays on limited range of each node broadcasting its presence. In case of AP+client mode you need to constantly scan and maintain connections. It does not seem very efficient at first glance.

    1. Yea. building and uploading the source is really easy with the latest SDK.
      But the Python interpreter is accessible through the UART link. What I wanted was to telnet into the interpreter. Would be cool to see that functionality.

    2. The ESP8266 implementation of Micropython is basically not much more than a proof of concept, and there doesn’t seem to be much interest in continuing its development (especially since one of the contributors to Micorpython has a product on kickstarter that directly competes with thsi). At the moment you have the basic GPIO and ADC working, together with the basic network sockets (in station mode, but there is a trick to get it into AP mode too). There is no timer support, and no way to have your program run its main loop while still having all the wifi stuff working (you have to return to the prompt to have all the events processed). Also the size of the python program you can run is severely limited. I wouldn’t count on Micropython as the main development option for this platform.

    1. I’m not sure what method is failproof, but i ordered a handful from ali express, used a $9 serial converter from amazon, installed cp2101 driver, flashed with esptool and programmed with esplorer and it has never failed to work. That is until I shorted 120v to the 3.3v bus. esp-12 survived, mac survived, but i needed to order another serial converter…apparently not totally failproof.

  2. I am using the ESP8266 with nodeMCU. This uses the Lua language. I like the fact that they support MQTT and COAP protocols and have some JSON support which is great for small IOT projects. Unfortunately the COAP implementation is not yet ready for primetime but when it is, it will be a great platform for simple objects such as temperature sensors, power switches etc. I would love to have node.js support, though!

  3. As this seems to be a bit of a point-of-reference for ESP8266 newbs, a quick implementation/conceptual question:
    For the various firmware reprogramming methods (including everything from arduino to bare-metal) there’s still a need to access the various protocols… wifi, TCP/IP, whatnot… So, when reflashing this chip, does that code come as a library, or is it hard-coded? What does the “user”/firmware-code-level interface to these things look like, once the AT commands are removed?

Leave a Reply to James PurcellCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.