ESP8266: This $5 Microcontroller with Wi-Fi is now Arduino-Compatible

Alasdair Allan

Alasdair Allan is a scientist, author, hacker and tinkerer, who is spending a lot of his time thinking about the Internet of Things. In the past he has mesh networked the Moscone Center, caused a U.S. Senate hearing, and contributed to the detection of what was—at the time—the most distant object yet discovered.

255 Articles

By Alasdair Allan

Alasdair Allan is a scientist, author, hacker and tinkerer, who is spending a lot of his time thinking about the Internet of Things. In the past he has mesh networked the Moscone Center, caused a U.S. Senate hearing, and contributed to the detection of what was—at the time—the most distant object yet discovered.

255 Articles

Article Featured Image
The ESP8266 microcontroller with onboard WiFi

The ESP8266 microcontroller with onboard WiFi

This is the 1st part of a series of 3 posts on the new ESP8266 microcontroller

I only talk about a bare handful of new boards because most of them don’t pass my test: whether they’ll let me do something today that I couldn’t do yesterday.

But every once in a while a new board, or a chip, comes along that makes me sit up in my chair. The ESP8266 is one of those, and the things that make it interesting is that makers are coming up to me and telling me about it. There was no marketing company here, this has all been about the community.

The ESP8266 is a UART to WiFi SoC built around a Tensilica Xtensa LX3 processor — shipping on a somewhat bewildering variety of breakout boards — the most commonly available being the ESP-01 which has a tiny form factor and can cost less than $5, although it’s more typically priced around $7 for low volumes.

The ESP8266 SoC on an ESP-01 breakout board.

The ESP8266 SoC on an ESP-01 breakout board.

The boards, and the underlying ESP8266 SoC, was initially marketed as a Serial-to-WiFi adaptor, and comes with a firmware supporting a simple AT command set to configure and control the wireless module.

What most people initially missed was that the SoC was fully programmable, this was a general use micro-controller, with Wi-Fi and — albeit somewhat limited — GPIO, all for $5 or less. This probably had something to do with the fact that, at least at first, all the documentation was in Chinese.

However it didn’t take all that long for interesting things to start happening. Most of the initial effort was to get GCC running on the platform, but things quickly progressed from a functioning GCC through to an SDK, and on to other languages like Micro Python, and a Lua-based firmware that gave access to both GPIO and scripting support.

All the while building a community and accumulating documentation. Still, things weren’t what you’d call easy. However all that changed over the weekend as Richard Sloan and Ivan Grokhotkov released a version of the Arduino IDE that supported the ESP8266 — and just in time for Arduino Day. Happy Birthday!

What’s Supported by the Build?

The short answer is quite a lot — basic functions like pinMode, digitalRead and digitalWrite work as you’d expect. As do interrupts, and the millis and micros functions, and sensible things done to delay to take account of the background activity of WiFi and TCP tasks, and there is a Ticker library for calling functions with a certain cadence.

The Serial object also works as you’d expect it to, and the environment ships with a custom libraries to handle WiFi that looks and acts mostly the same way as the official WiFi shield library.

There is also support for EEPROM — although it doesn’t quite work the way you’d expect — and limited I2C support, alongside OneWire and mDNS support. Basically, any third party libraries that don’t rely on low level access to the AVR should work, although there hasn’t been extensive testing as yet.

Why should I use the ESP8266?

While the ESP8266 can’t do everything you could do with an Arduino — for instance it only has one PWM pin that isn’t even exposed by the ESP-01 breakout board we’ve used here, you’d have to go looking for something like the Olimex board that Sandeep was using to get access to it — but for $5 it’s a bargain.

For $5 it doesn’t have to do the same amount as you can do with an Arduino, because at $5 you can afford to buy 5 or 6 of them for the price of a single Arduino board.

“This is inexpensive enough to be very much in the territory of ‘thousands of sensors-launched-out-of-a-cannon’-cheap.” — Brian Jepson

The ESP8266 was already well on its way to becoming — almost by stealth — one of the leading platforms for the Internet of Things. It’s super cheap, and super easy to work with, and it’s actually fairly easy — as such things go — to get your hands on, which makes a refreshing change.

However the arrival of Arduino compatibility is step change, suddenly the growing but still small community has opened their platform up to a much larger community. Suddenly there is a huge pool of people that  know how to work with the board, and I think we’re going to see an explosion of projects and products that otherwise wouldn’t get made. Because suddenly we have our hands on a WiFi board, that we all know how to use, that’s almost cheap enough to throw away.

Get out your soldering iron and buy some boards, I’d love to see what you build with it. Especially if it involves cannons.

This is the first of three posts on the ESP8266 microcontroller. The second part of this series covers installation of the new Arduino environment and building and uploading your first sketch to your ESP8266 board, while the final part discusses creating a breadboard adaptor for the ESP-01 breakout board.