Tag Archives: ESP8266 lost connections

ESP8266 Reliability and ID

Questions for you C programming ESP8266 guys re: the ESP SDK (1.2.0) and some possibly important info on WIFI and MQTT reliability.

In the SDK:



HOST ID….  If you do an IP scan on a windows network – ESP units will coming up as IP addresses – and Manufacturer ESPRESSIF…   there is a WIFI HOSTNAME GET function in the SDK -  but not only can I NOT get it to do anything, the corresponding GET function returns something like ESP_945645  - and not what I put in and NEITHER are showing up in the Windows IP scan – so the question is… where are you supposed to use the SET function in the SDK to replace the info that comes out of the GET function – and why isn’t any of this showing up on a Windows scan.


I discovered that if our software was running happily on the ESP12, happily talking to MQTT, if I then disconnected the WIFI and router for a few secs and reconnected…… DEAD. The board would respond to serial but it had LOST the WIFI number.

No amount of waiting would fix this – I wonder how many people have NOT twigged to this – well, if not – this could be your lucky day. The reconnect policy set to 1 will ensure that within a few minutes, the IP will reconnect.. and of course you can CHECK this!!!

So the next step was to see if the IP had been reconnected and call the MQTT reconnect routine – after all, you’ve lost all your MQTT subscribes at that point.

Then it occurred to me – there might be other circumstances – the NODE-RED might have gone off for a while – could I be sure I’d still have a connection – so finally we set Node-Red off sending a “heartbeat” message to all of the units (by missing off the unit name and just having a topic of “toesp” on our boards, you send to all) every minute – and that resets a timer – so then in the above routines – if the WIFI is active and the timer has timed out – once again reconnect to MQTT.  I checked the stack and this does not suffer – so fingers crossed that will be just fine for the odd occasion that this is needed.

Hence reconnect without rebooting and all the horrible relay flicking results of that!!!  I’m quite happy – a beer, I think. The repository is updated and I have boards testing now.

If you are using MQTT and C on your ESP8266 boards, you might just want to ponder the above and if you have an answer for my query at the top, please do let me know.