Wednesday, 9 March 2016
The tiny little ESP8266 based ESP-01 gives you a microcontroller with decent Wifi support for very little money. I've just ordered some from China for £2.28 each.
It started out as a serially connected faux modem driven with AT commands intended to slave off other devices and get them on Wifi. With the SDK and a pile of useful info publicly available from the chip manufacturer soon there was alternative firmware floating around that let you actually use it in its own right to do things.
This variant of the board only has two GPIO pins you can use but the chip itself has loads more and there are now a whole slew of boards around that expose more these, notably NodeMCU.
Anyway I bought five of these almost a year ago and chucked them in a storage box, mostly because the pinout is breadboard-unfriendly and I was busy with other things.
Now I'm in the position where I'm building some props that ideally need to interact with people via Wifi and a browser so I hunted round for these and started to have a look.
First thing to do was update them and by pure accident I put the NodeMCU firmware on, rather than the AT firmware. I've previously stayed away from nodeMCU because I didn't want to learn yet another programming language. This mistake was quite fortuitous though as reading around the subject it seems NodeMCU has some really nice features and is powerful enough to allow me to offload the user interface stuff I need to the ESP-01.
The Lua programming language is interpreted and seems to have a few foibles but as implemented on the ESP8266 looks really useful and comes with great stuff like read/write access to a basic persistent filesystem in the flash memory of the device. This is where the Lua programs are stored and it always runs 'init.lua' on startup but you can have more than one .lua file on there and call them later if you wish. OK you've only about 64KB to play with but it gives you a place to store things too and this will probably be just right for my application. You can even upload files to it from a PC with some community contributed applications.
Should you be so minded it can run a minimal but conventional web server that serves files and at a push does basic CGI scripts with Lua. Although this is very much pushing the bounds of what it was designed for. I probably won't go this far but I can see myself embedding a basic server that responds to AJAX requests from another page.
I'm definitely late to this party but when the ESP8266 boards first came out they were a bit limited and seen as 'quirky'. Now after a year of community development this is really interesting stuff and I can see myself using it a lot this year.