ESP8266 happiness

It just goes to show that perseverance sometimes pays off. It turns out that the reason I couldn’t get the Olimex esp8266 to work properly was that my USB/serial converter was faulty. The replacement one arrived today, and now I can program the wifi module using the arduino IDE with no problem. Five seconds after programming it, it had connected to my home network and was sending temperature readings via MQTT to my raspberry pi server. There are plenty of IO pins exposed on the Olimex module, so I can do lots more with it than with the wi07c module I was using before. Watch this space.

ESP8266 disappointment

I found a very promising new ESP8266 module, from Olimex (a Bulgarian company).

MOD-WIFI-ESP8266-DEV-1

It’s a breadboard-friendly board with an ESP8266 and 512k of flash memory on it, and it’s dead cheap. There’s even a carrier board for it, with a relay and a reset button, also dead cheap. I bought a couple, because it exposes all the pins from the microcontroller, so I can (a) use more than one I/O, and (b) hook up the reset pin so that I can put the device into (and, more importantly, wake it up from) deep sleep mode to extend battery life. There are videos on line of how simple it is to program these devices using the new arduino IDE.

The (insert strong adjective here) problem is that I can’t (insert strong adjective here)-well get it to work. I can connect it up to my PC fine. I can even put it into flash mode perfectly well. In neither case will it respond coherently to anything sent to it from the PC. In ‘normal’ mode, it just repeatedly sends the word ‘Error’ over the serial link, and does not respond to any AT commands.

Olimex ESP8266 errors

In reflashing mode, it simply fails to respond to the reprogramming commands. I’ve tried two of these modules, and both behave the same. I’ve contacted Olimex both by email and on their forum, and had no response. It’s a shame, but I think these modules are destined for the rubbish bin. At least they weren’t expensive.

Update: Olimex have got back to me, and have made some helpful suggestions. They don’t know what the problem is, though, and it’s not one they have seen before. It may well be something to do with my serial adapter. I have another on order, so I guess I’ll find out in due course.

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.