Firstly let me say this is not intended to be authoritative, so please don’t come back to say I have it all wrong… these are just my views for now – they may change as things develop.
You may have noticed I’ve been taking an active interest (there’s an understatement) in the development of firmware for the ESP8266-type WIFI boards. Why? Well I see this little board as a saviour on two fronts:
1. As a low-cost stand-alone unit – using either C or a higher level language to make the ultimate in low cost controllers.
2. As a means to accessing the Internet for Arduino and other microcontroller systems at low cost.
Up until now, the lowest-cost means of scattering devices around an area included the likes of the NRF24L01 radio modules, at around £1 each you don’t get much cheaper, but they have very limited range. This can be mitigated somewhat by networking software and in my own homes and elsewhere I am using a network of Arduino-type devices to control and monitor heating and lighting. It works – but the hoops you have to go through to get range make it not a lot of fun. Low cost alternatives include RS485. Again at around £1 from China you can get RS485 interface boards and these are fine – but you have to wire everything together.
In my case the whole thing is held together by a master board using hardwired Ethernet to talk to the outside world. All well and good but for all the wires and intermediate wireless points to boost the range.
And then along comes the possibility to use WIFI. I have simply dismissed the alternatives available at £10+ as the cost per point starts to become excessive – especially for anyone doing this as a hobby.
A few weeks ago, the ESP-01 and similar boards appeared out of the woodwork, a dirt cheap Chinese WIFI board around the size of the NRF24L01. At first I started to think of them as a simple cost-saving replacement for my own main Ethernet card and so I was very interested in the AT version released by Espressif. To explain: The little board uses serial control to talk to a host microcontroller such as an Arduino. I have spent every spare minute on this as we’ve gone from a board being released with almost useless firmware, to the point where today we have maybe 3 viable options for taking this forward and I’ll go into that in a moment.
The hardware: The ESP-01 is probably the most popular design and sadly it is not ideal. The tiny board has an 89-pin header and it’s sole saving grace is that it is CHEAP – just over £2 at best. It has a PCB antenna which works but doesn’t give the best range but it’s save to say that if you have routers offering a strong signal throughout the building, this board will work for you. As a unit designed to work with, say an Arduino, it is perfect. As a stand-alone board it is useless as you only have simple access to one pin! The problem there is that with 2 pins you can implement, say, I2c which opens a whole world of peripherals. With 1 pin – well, you can flash a light or read a temperature sensor.
There are others, the ESP-03 design brings out the pins to the edge of the board. In both cases these boards use 3v3 – which is fine unless you consider that many controllers and many peripherals run on 5v and those microcontroller boards which offer 3v3 do so with insufficient current to safely power these boards which can use up to 250ma (tiny 3v3 regulators often supply only 100ma).
In my experience, while powering the boards with 3v3 you can feed the output directly to, say a 5v Arduino but you need at a minimum a resistive divider to the inputs – that is the serial input – and the reset (and you really do need to be able to access the reset). There is even a board out there which I won’t discuss which has access to power and serial only – that is dead in the water for me.
What I would LIKE to see is a 5v compatible board with internal aerial, the pins available on 0.1” centres and an optional aerial socket for external aerial. Do I want this? YES, do I want to pay over £3 for it? NO. Therein lies the issue. Only the Chinese can make that happen at the price.
What absolutely is needed is a minor change to ESP-01 to bring out at least one more port wire. The magic phrase… “I2C”.
The software: This has been an absolute minefield and I would say it is only in the last 2 days that I’ve come to the conclusion that we have a real winner of a board here. There are to my mind 4 routes to potential success available to us, depending on our requirements…
1. The original Espressif software. To call this awful up to now would be generous.. Using the existing software is a nightmare as it has bugs – several trivial and one major. The “busy…s” problem is firmly embedded in my brain as a timeout which won’t go away and as for some of the error messages, “no is fun” comes to mind. However as of yesterday, an as-yet unavailable version seems to have tamed but not eliminated the first problem.
I have an Android App for my mobile phone which controls 4 outputs on an Arduino which is using the ESP-01 board. Until yesterday I could not keep it running for more than a few minutes without the dreaded lockup. The busy issue still appears but is now an inconvenience. My App has not fallen over in 20 hours (to keep this in perspective, my Ethernet-based home controllers have stayed up for well over 1100 hours without a hitch). I am relatively confident that if Espressif continue to develop this we will have source code access to working software within days or weeks.
2. Frankenstein. There is one complete re-write of the software, no longer using AT commands which, until the designer got the flu last week was starting to look promising. Badly documented to date this is a potential alternative to the Espressif software.
3. There is, floating around, an implementation of a standalone web server designed to initially turn a LED (or whatever) on and off from the ESP-01 etc. using the board itself with no external support. This can act as a router for setup and via a web page can be set to use your router. Another fellow has developed this to read temperature and you can see the possibilities here… but right now, it is NOT a practical solution as there is a bug in the setup software which means the part where it runs stand alone and gives you a list of available routers… doesn’t actually work. You end up having to FLASH the original Espressif software to setup the router – then re-flash this software …. erm, no thanks.
I do have promises this will be fixed and if and when that happens, I think this has a niche all of it’s own – not in it’s original form but with custom software to make better use of I/O.
4. Finally, one great hope is a development that puts a LUA-based interpreter inside the ESP-01 etc. and allows for a stand-alone unit needing no other hardware. See my notes however about I2C and the need for another pin. So – WHAT ON EARTH is LUA? I’d never heard of it until last week when the first implementation came out – which didn’t work properly. I am about to test the update completed only hours ago and a colleague of mine is already onto it and getting excited. Essentially LUA is a high level language interpreter. You can send commands, functions and even complete programs and data to the ESP-01 serially and have them run on the board with nothing else but power attached.
There is even a start up function you can send which will ensure the board acts sensibly on power up. If you are familiar with C and Java etc you’ll find LUA reasonably straight forward but you might want to get something printed out. The ZIP file for this software contains a lot of info and if you look up LUA on Google you’ll find a complete reference website – concentrate on the features of version 5.1, not 5.0 or 5.2 (as far as I can tell).
Today I intend to give this last option a good hammering – one of the features CLAIMED to work with e LUA version is I2C. Now, how you do that with 1 wire I don’t know, I suspect on the ESP-01 it’s going to involve micro-surgery but we’re still trying to work this out. But think about it – even if it’s slow (as interpreters tend to be) if it will act as a web client and web server that’s half the battle (reading time servers etc., remote access) and the ability to handle I2C means the little board on it’s own, with no compiling from your perspective, can talk to a myriad of devices including port extenders, clocks, LED drivers – there are thousands of devices out there that talk I2C ( for the uninitiated, a 2-wire bus where devices have addresses and can talk both directions). Remember that this is not an Arduino – it’s a powerful little Microprocessor with a reasonable amount of room – the possibilities are huge.
We have cheap WIFI devices, we have at least one company working on a prototyping board for them, we have many suppliers ensuring we should have reliable access to the devices…what we need is for at least one of the above options to mature to the point where we can rely on them to do whatever it is we want them to do. I could see, best case, these things being a fantastic, low-cost alternative to radio networks for so many applications around the home and office. Sadly the current devices use a lot of power which makes solar operation “challenging” – but that’s just for now – you never know what might happen tomorrow. What would really be nice would be a cheap supply of the actual chips so those of us with PCB abilities could make our own versions.
Everything I describe above, has links in my previous blog items in here. I am so lucky as a man who spends his life going from meeting to meeting around Britain and Europe that at this very time I’ve a short lull in said meetings which means I can spend a little time indulging in this challenging but exciting development. I don’t normally get the time to do this so please, take advantage, do look in over the next couple of days to see what’s new – it’s changing by the hour.