After much perseverance at getting the AT command set for the ESP8266 to simultaneously act as socket listener and web client I eventually decided to read the guide – and that’s when the dark cloud appeared. You have to RESET the unit after changing mode – so there is NO chance of doing this simultaneously.
After I’d decided NOT to cut my wrists, I sat down yesterday and wrote the code for my Arduino+ESP-01 (well, my 1284 Arduino – same thing but 2 UARTS and more memory) and wrote a little routine so that every hour on the hour, the unit would switch modes, get the time from a web server, send off the temperature and then reset and go back to socket listener mode.
The result… since teatime last night and this morning it’s done just that on the hour without a hitch.. and the rest of the time (maybe 15 seconds of non-availability every hour) it’s working just fine talking to my Android App.
Right now the code’s a little crude – I need to modify my input checker (watches for replies with timeouts while waiting and after receiving – and offers optional capture of incoming info between starting and ending strings so that I can add retry options and reboot the board on failure. Right now the routine is blocking – I need to think of a non-blocking version so I can get on and do other things while it’s waiting for replies… I’ll put the code in here and let others comment soon.
So in essence, it works – I can soon adapt this into one of my home controllers with temperature control and at last be free from the evils of Ethernet cable.
New: Well, nothing really, no updates to Lua, no updates to the AT code or the SDK that I’m aware of – after a flurry of activity things seem a little dead right now. Off to see a friend at the weekend who has the first of some boards we had made in China to mess with ESP-01 boards – more when we get started with the soldering iron.