The King is dead. Long live the king!

For a while now, I’ve been playing with the super-cheap esp8266 WiFi module. It’s been a bit of an uphill struggle, mostly because of the poor documentation (actually, that’s not fair – the documentation may well be excellent, but my understanding of Chinese isn’t) and the lack of easy programming tools. Until now, there have been essentially three ways of using the module:

Serial for breakfast

The initial method was to control the module via a serial link. As supplied, it can communicate with an arduino (or anything else) using a simple serial connection, using AT-style commands which will be familiar to anyone who has worked with modems, especially GSM ones. It works, but it’s a bit clunky. By and large, I think people have stopped doing this.

C for elevenses

Pretty soon after it became available, smarter people than me figured out that the module is powered by a general-purpose microprocessor (and a pretty powerful one at that). It also became apparent that you could reprogram this directly, and use its spare capacity (and spare I/O pins). Thanks to the manufacturer’s release of an SDK, it became possible to write code directly on the module, without the need for an arduino or any other processor. For less than five pounds, you could have a general-purpose microcontroller with build in WiFi.

Of course, there’s a catch. The tool chain required to do this programming is hard to set up and complicated to use. It also means programming in C and understanding a pretty complex SDK. It’s not particularly friendly. There were some valiant efforts to make this easier, notably Mikhail Grigorev’s bundling of everything into the eclipse IDE. This works well, but it still requires you to program at quite a low level.

lua for lunch

More recently, there has been nodemcu. This is a new set of firmware for the esp8266, which builds in an implementation of the lua language, with the SDK functions wrapped and easy to use. Nodemcu allows you to write programs in lua, upload them to the esp8266 and run them on it. This works pretty well. I’ve had temperature sensors in my house using it for a while, It has some drawbacks, principle amongst which is that the nodemcu firmware takes up quite a lot of the available memory, leaving fairly little for your programs. Add to this the fact that your programs are sent to the device as source code, and interpreted (or compiled) in place, and you find that there really isn’t much space to write more than simple programs. This shouldn’t be an issue for small sensor nodes, but I found myself scratching around trying to save a byte here and a byte there just to get my code to run.

Arduino for dinner

What everyone has been secretly waiting for, of course, is the ability to program the esp8266 like an arduino. And now we can. There’s a new version of the arduino ide 1.6.1 which gives you the ability to program the esp8266 using familiar arduino code. The wifi functions are easily available, as are most other arduino functions. It’s insanely easy to write something which connects to a wifi router, gets an ip address and sends data to a server. Or indeed to run a server on the device. Because the arduino language is compiled to native code before being uploaded, there’s loads of space for programs. Some of the normal arduino libraries have not been ported yet, but I’m sure they will be in the coming weeks. I won’t be going back to any of the other methods. Long live the king!

It’s worth repeating that the esp8266 gives you a tiny board with a 32 bit processor running at 80MHz, at least half a megabyte of memory (my recent olimex ones have 2MB), multiple IO pins and wifi for less than five pounds. If I were arduino (whichever half of arduino you care to pick) I’d be worried.

4 thoughts on “The King is dead. Long live the king!

  1. So if you want to program stand-alone ESP8266 using Arduino IDE 1.6.x, then what board do you select?

    • From the Tools menu, select the following:
      Programmer: esptool
      Board: Generic ESP8266 board

      That works for me (except for the Olimex ESP8266 board – see my blog post on that 🙁 )

  2. Hi Peter, can you please point us towards a supplier for an ESP8266 that has worked for you (I know you’ve struggled with at least one, I didn’t want to go down the same frustrating route!). We fancied having a play with one in the office…

    I’ve been messing around with LCD TFT screens for Raspberry Pis the last couple of weeks – there was a good cheap 2.8″ one that gives 320×240 from China which runs really nicely at around 60fps, even on an original model B Pi and a bigger 3.5″ 320×480 which runs X11 fine, but has a refresh rate that is too slow to (for example) play side-scrolling games using MAME (even on a brand new Pi2 Model B)… I’ll bring them along to C4DI next hardware meet.

    • I bought my first batch from electrodragon (http://www.electrodragon.com/product/esp8266-wi07c-wifi-module/), and they work fine (now that I know what I’m doing with them). There are loads of other suppliers for the same module on eBay. There are two downsides to this particular version: firstly, the pins are arranged in two rows of four, which makes it impossible to plug into a breadboard. I had to build a separate adapter board for it. Secondly, not all the processor’s IO pins are exposed. This last is not necessarily a problem, but if you want to put the device into very low power sleep mode (and wake it up again) you need access to them. I want to use battery power, so I need the sleep mode. On the plus side, the device is tiny.

      There are other varieties of esp8266 board (electrodragon do them too: http://www.electrodragon.com/product/esp8266-wifi-board-full-ios-smd/) which are larger, more breadboard-friendly and expose more pins. I haven’t tried them, but they are the same chips simply on a different carrier.

      Finally, I’ve bought some devices from olimex (https://www.olimex.com/Products/IoT/MOD-WIFI-ESP8266-DEV/open-source-hardware and https://www.olimex.com/Products/IoT/ESP8266-EVB/open-source-hardware), but I am having problems making them work. I seem to be alone in this, as everyone else who has written about them on the internet says how easy they are to work with. I have a suspicion that my problem lies with may serial adapter and/or my PC rather than the device itself, but I lack the hardware tools to be sure.

      The displays sound very interesting. I’m using a pi as a server to receive temperature data from the wifi modules around my house. It would be nice to give it a low-power display showing all the graphs.

Leave a Reply

Your email address will not be published. Required fields are marked *