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

Arduino Internet of Things Maker News
ESP8266: This  Microcontroller with Wi-Fi is now Arduino-Compatible
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.

39 thoughts on “ESP8266: This $5 Microcontroller with Wi-Fi is now Arduino-Compatible

  1. Guest says:

    iluyutuu . true that Patricia `s report is impossible… on wednesday I bought Saab 99 Turbo since I been making $8569 thiss month and also ten/k this past month

    . it’s actualy my favourite-work I’ve had . I began this three months/ago and pretty much straight away was earning more than $75… p/h . you could try here MORE DETAIL HERE

  2. Edwin G. Delgado says:

    Is it a stand alone board or must it be connected to an Arduino to get the most of it?

    1. Alasdair Allan says:

      It started off as a UART Serial WiFi adaptor you could use along with an existing Arduino board, but this makes it a standalone board that works with the Arduino development environment on its own, See https://makezine.com/2015/04/01/installing-building-arduino-sketch-5-microcontroller/ for details of how to make that happen.

  3. hatchr says:

    If this is an April Fool prank, I’m going to be angry.

    1. Alasdair Allan says:

      It’s not an April Fool’s prank. This actually works. See the next post for details of how to get it working, https://makezine.com/2015/04/01/installing-building-arduino-sketch-5-microcontroller/.

      1. Guest says:

        I’am freelancing at home, working some basic jobs which only requires from you a computer and internet access and I am so happy with it… After 6 months on this job and i got paid so far total of 36 thousand dollars… Basicly i earn about $80/hour and work for 3-4 h most of the days.Best part to whole this thing is that you can make your own schedule when you work and for how long and you get a paycheck weekly. -> Check IT out Here <-

  4. William Weatherholtz says:

    Very well done. Make has earned my respect.

  5. Mahmod Abdullah says:

    Going to buy this board

  6. Eugene Goostman says:

    I love this board, more specifically I love buying ESP-12s for $2.50 ea, rather than the $7 noted above.

    What will complete my love is when I work out how to store the SSID and password ‘in situ’, so I can take a device to someone else’s network and connect up, without having to reprogram.

    1. James Heires says:

      Eugene,
      I share you desire to produce a wifi-enabled product that appeals to the masses – enable simple user input of SSID/Pass. Although I haven’t yet solved this, I have these 2 ideas: 1) Use bluetooth to connect to a device (smartphone) and query the user for credentials, 2) Use available auto-detect wifi sketch to find any available open network connections (depends on being in range of an open network: not the best solution), 3) Produce a point-to-point wifi connection and a companion website/mobile app that talks directly to your 8266 to provide wifi credentials (I recently saw a posting on this, and it sounds like the best solution I’ve seen for this problem).
      Good luck – please share your progress.

      1. James Heires says:

        Eugene,

        Have you seen this instructables on bluetooth Arduino connections (http://www.instructables.com/id/Add-bluetooth-to-your-Arduino-project-ArduinoHC-06/?ALLSTEPS)? I just built it, and to my surprise, it worked perfectly using the 2 examples given. Next for me is to query the bluetooth client for SSID and Password for a wifi router, and pass this to my wifi connection sketch to connect. I’ll let you know how if works (if I can ever get my 8266 working!).

        1. Eugene Goostman says:

          James, thanks a lot for the links. for some reason I didn’t get the Disqus notification. Lots of interesting stuff – I never thought of using BT to set SSID credentials. I have a ton of BT modules :)

          Going to the parts bin as we speak :)

          Cheers.

      2. Eugene Goostman says:

        “Produce a point-to-point wifi connection and a companion website/mobile app that talks directly to your 8266 to provide wifi credentials”

        I too have seen that – but coding an iOS or Android app is above my pay grade :)

        What I did think of was:

        Create a default AP SSID with default (or no) security.
        Create a web page on the ESP that you can use to change SSID and password.
        Join the network and navigate to the web page, enter in the credentials for the network (or take the option that sets it all back to defaults) and restart the ESP to join the secured network.

        EDIT: Actually, exactly what you said – Doh! :)

        1. James Heires says:

          Eugene,
          This open network idea sounds good, if I understand that the AP is implemented on your 8266 with a point-to-point network connection to a browser, to set the SSID/Passcode.
          Would you share your solution when you have it working?

          1. Eugene Goostman says:

            Works perfectly.

            I have a Mac, so the toolchain isn’t perfect, but I have been using ESPlorer, which is a great IDE and file management tool for the ESP: https://github.com/4refr0nt/ESPlorer

            It’s Java, so works cross-platform.

            The other tool I used was esptool for loading the NodeMCU firmware: https://github.com/themadinventor/esptool

            That’s a lot of fun to get your head around :)

            And the code is on pastebin : http://pastebin.com/KHpUNnsR

            Once I sorted out the syntax and translation issues regarding PC:Mac, it worked out of the box (yeah, that sounds so easy compared to the 6-8 hours I spent :) )

            I tried it on a number of different NodeMCU firmwares, right up to bleeding edge, and it works with all of them.

            Horacio Bouzas did a great job!

            The process: Ensure you have NodeMCU Lua firmware on your ESP: https://github.com/nodemcu/nodemcu-firmware/tree/master/pre_build (I used ‘latest’)

            Load up ESPlorer and connect with your ESP, copy the code from Pastebin into a new document, save it as init.lua and it will write it to the ESP. Reboot.

            You should see an SSID of ESP_STATION (or whatever you called the SSID) with a password of ‘password’. This creates IPs in the range 192.168.4.x. Join that and navigate to 192.168.4.1 and you will be presented with a web-page. Enter your ‘real’ SSID and password and it will run off and join that AP.

            The web page stays active on the new AP, so you can change it again. The change is retained across reboots.

            Now all I need to do is work out how to get mDNS working, then I can call the device ESPxx.local and it becomes truly portable.

          2. Eugene Goostman says:

            I spoke too soon – something I did at midnight broke it… and I am burned out right now. I will have to look at it later.

            Feel free to try and debug it – it seems to be in the place it joins to the new AP. maybe the mode is wrong… I will look at it later.

          3. James Heires says:

            Eugene,
            Looked at the code on pastebin and didn’t see anything odd in the AP mode code.
            My source is almost identical in this area, and it works (at least when I send it as text to the 8266 with CoolTerm).
            Are you getting an error message, or is it just not setting up your AP?

          4. Eugene Goostman says:

            It’s setting up the original AP, creating the webpage, but when it goes to the next step it gives an error and reboots.

            I am flat out today with other stuff – I will make a proper PCB for flashing/loading tomorrow and have another go.

      3. Eugene Goostman says:

        Found it! Horacio Bouzas has written a nice step-by-step tutorial to doing exactly this using a web page.

        http://horaciobouzas.com/2014/12/24/esp8266-based-web-configurable-wifi-general-purpose-control-part-ii/

        1. James Heires says:

          Thanks for the link! It sounds perfect! Have you built it yet? I tried yesterday but my 8266 kept restarting partway through which caused the lua interpreter onboard to miss characters and throw errors.

          1. Eugene Goostman says:

            I just received a new unit in the mail today that I am using for development – a NodeMCU dev board with USB and a fully-broken-out PCB.

            I will have a go at it tomorrow.

          2. Eugene Goostman says:

            I’m having some really funny results just trying to load programs.

            I can upgrade firmware easily enough, but trying to loa a LUA file get lots of ‘unexpected symbol near ‘�” messages.

            I am on a Mac and the toolchain doesn’t seem as full as for PC.

          3. James Heires says:

            I just learned of a luatool from 4refr0nt (see 4refr0nt/luatool on git) that should work on mac (I’m on Windows), cuz it’s python based. I downloaded python 2.7 and pyserial, then got the luatool, and was able to send my lua script (init.lua) to my 8266 non-volatile memory. Now, I’m able to power cycle my 8266 and it remembers the AP credentials (this was working before), and automatically runs init.lua as well. I have a simple LED remote control program now, but it demonstrates the solution to my satisfaction.

            Next for me is to modify my lua script to query the user for SSID/Passcode for their Wifi router (probably using a simple web page), then switch from AP to STATION mode and connect to the router. I’m planning on trying Horacio Bouzas’ solution (http://www.instructables.com/id/ESP8266-based-web-configurable-wifi-general-purpos-1/), FYI.

          4. Eugene Goostman says:

            That was a problem with ‘ ” copying from a web page to the mac. Sorted now.

            I am using 4refr0nt’s ESPlorer – great tool, Java-based. A proper IDE with Lua notation checking, etc.

            https://github.com/4refr0nt/ESPlorer

          5. Eugene Goostman says:

            I had the same problem – it turns out that in order for Horacio’s instructions to work, you need to do it exactly the way he says – including using the tools he used. I am on a Mac, and the cut-and-paste caused issues, so I ended up pulling it into a development editor and hacking it up till it worked.

            I loaded it through ESPlorer.

            See my post below for full details – it’s fab! I am going to dive into how to go further once your device is on a network and present a further webpage for module control.

            That may take some time.

            The other thing i want is to get mDNS (avahi, Bonjour) working, so you can refer to the device as ESPxx.local, instead of having to track it down by MAC address/IP address.

            Good luck – give me a shout if you get stuck.

    2. James Heires says:

      Eugene,
      Was able to collect wifi credentials (SSID/Passcode) over bluetooth with a simple sketch and an HC-06 BT module (see image). Sketch is crude and has one annoyance – my BT module does not seem to know where the user ends his/her input, so it reads characters only for a short while (~1 sec). I was hoping I could terminate user input with CR/LF, to give the user more time. I’ll work on this aspect, to make this more user-friendly, but somewhere I read that this is a quirk of the particular BT module I have.
      Let me know if you have ideas.

    3. Tarun Vaghasia says:

      How can we store SSID and Password ‘In situ”??

      1. Eugene Goostman says:

        This technique works: https://github.com/sebastianhodapp/ESPbootloader (although I think there are a couple of coding errors – it’s enough to get you going).

        Essentially you create your own AP and a web server that offers up a web page where you enter your SSID and password. It creates a file, then reboots and uses those credentials to log in. Essentially the same process as the Spark Core or Electric Imp, without the smartphone app and flashing lights.

        I have had it working about 5 weeks now and it works every time – even with non-technical users.

        I can send a board to someone halfway round the world and with some simple instructions, they are able to install it and get it on their network in a short time.

        The next thing to do is to implement mDNS, so they can talk to it as esp.local, instead of having to know the IP address (although the initial web server is always the same address, so the instructions are easy to follow – I have the instructions as a web page, so it’s a point-and-click exercise, apart from joining the temporary AP).

  7. James Heires says:

    First, I just love this development! Should make us Arduino developers happy, if we could only get it to work…

    I’ve tried to reproduce these results myself and have so far been unable to load the example WiFiWebServer example onto my 8266 (tried 2 different modules, and 2 different USB interfaces and all 4 permutations of same). So far, all I see is a warning and an error message when I attempt to upload the sketch:

    Sketch uses 208,184 bytes (39%) of program storage space. Maximum is 524,288 bytes.
    warning: espcomm_sync failed
    error: espcomm_open failed

    Anyone else get this error and resolve it? If so, please share your experiences.

    1. James Heires says:

      OK – after replacing my 8266 module with a new -01 model, I’m able to flash the device with the ESP8266 Flasher utility without issue. The Rui Santos lua script works swimmingly (http://randomnerdtutorials.com/esp8266-web-server/#comment-254466), but Horacio Bouzas’ script (http://horaciobouzas.com/2014/12/24/esp8266-based-web-configurable-wifi-general-purpose-control-part-ii/#comment-440) fails due to “not enough memory” error reported by ESPlorer.
      Has anyone else run into this?

      1. James Heires says:

        After some additional research on lua, I’ve learned that “not enough memory” could be related to the lua interpreter, and some problems with the script. For example, if an endless loop were encountered, the lua interpreter would eventually run out of memory attempting to elaborate the statement(s). What I found to be helpful is to use the “Send to ESP” command on ESPlorer, where one line at a time is sent and interpreted. If an error occurs, I have some idea where in my script the issue lies.

        In the case of Horacio’s script, I see the following interpreter error (see image): “stdin: 1: unexpected symbol near ‘not’for count=1, tonumber(pl) do

        print(count)

        >>” The interpreter does not indicate which symbol wasn’t expected, and there is no text ‘not’ anywhere near this statement. So, needless to say, this is a confusing error message.

        So, I’m stuck again, for the time being.

        FYI: I downloaded Luaforwindows (https://code.google.com/p/luaforwindows/downloads/detail?name=LuaForWindows_v5.1.4-46.exe&can=2&q=), and it says the script is syntactically correct (exit code: 0).
        Could this be an issue with the nodemcu interpreter?

  8. Kaarle Kulvik says:

    awesome!

  9. Majenko Technologies says:

    Better still, this module, and the Arduino API for it, is now fully supported by the more advanced UECIDE environment (beta version only), so you can program it in comfort now. http://uecide.org

  10. Li Hongxia says:

    where I purchased NodeMcu+motor shield+wificar
    http://goo.gl/jKNYgT

    Some Documentation I found online:
    ESP8266 NodeMcu Dev: http://doit-nodemcu-dev.doit.am/
    ESP8266 NodeMcu Motor: http://doit-nodemcu-motor.doit.am/
    NodeMcu Wifi Car: http://doit-nodemcu-car.doit.am/
    WiFi Car Dev:http://doit-nodemcu.doit.am/index.html

    a Tutorial on CLOUD coding with NodeMCU
    http://bbs.smartarduino.com/showthread.php?tid=3

  11. Jupiterov says:

    There is an amazing new project based on ESP8266 that permits to control Arduino with smartphones, where Arduino can completely draw the graphical interface. It’s very powerful. With a single line of code you can draw panels with LEDs, buttons, plots, sliding bars, pictures, switches… the project website is http://www.miupanel.com , there are examples that show how to control a Relay via Internet, implement a multichannel voltmeter and even an oscilloscope with Arduino UNO

  12. Pion Pak says:

    Thank you for the very informative article. I have a question. I am using the wi-fi shield for my Arduino project and the wi-fi component is HDG104/HDG204. The problem with this component is that it’s too expensive ($20~$30+). So do you think this ESP8266 can replace it? Thanks.

  13. Michael Molinari says:

    Basic interpreter for esp supporting gpio. GUI wigets for browser. Simple web server. And 100% self hosting browser based programming environment.
    http://ESP8266Basic.com

  14. Giannis Demetriou says:

    Well, if you find me a tutorial on how to connect this to an arduino nano that is full noob proof (because most are not noob proof and I AM A NOOB) then I would love to use it :)

  15. ssw awab says:

    Actually you are wrong to say can buy 5 or 6 arduino. Please compare to the same apple to apple and orange to orange.
    If you want to compare why not china made arduino chip with esp8266? same chip vs chip! then nodemcu vs china arduino nano.

Comments are closed.

Discuss this article with the rest of the community on our Discord server!
Tagged

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.

View more articles by Alasdair Allan

ADVERTISEMENT

Maker Faire Bay Area 2023 - Mare Island, CA

Escape to an island of imagination + innovation as Maker Faire Bay Area returns for its 15th iteration!

Buy Tickets today! SAVE 15% and lock-in your preferred date(s).

FEEDBACK