I have a working ESP8266 that connects to a WiFi at home, gets some data from a UNO, posts it to the Thingspeak cloud and goes to sleep. Repeats this every 5 minutes.
I have a few queries on this implementation :
Leaving the ESP8266 permanently connected to WiFi router (Versus ] Connecting as above ? Which is better in terms of reliability as in this case power consumption is not an issue as it runs on mains. But the problem with leaving it permanently ON is that in case the ESP8266 crashes the link is dead till it is noticed.
With the 5 minute re-connect, this situation is handled.
Thingspeak free account does not allow posting at less than 15 sec interval. In case i want to post at say 30 sec interval, is it a good idea to open / close the WiFi with router so frequently ?
Or to have best of both worlds : When the ESP8266 first links to WiFi, start a countdown timer for say 1 hour. At the end of 1 Hour close and re-establish the WiFi connection so the link does not remain dead for more than an hour if the ESP8266 locks up.
Finally how effective is the ESP8266WiFiMulti library in handling many WiFi routers and connecting to the strongest ??
( PS : i know this post is best done in ESP8266 community but i am doing it here as the responses here are fast and precise !)
You are still using some power even if mains powered, so if you are only updating periodically I would say sleep the ESP8266, this also reduces a bit of heat being generated as well. The Wi-Fi router isn't really bothered either way.
Okay so if updating at a 30 second interval it probably isn't worth sleeping the ESP8266 between that short period of time. Again the Wi-Fi router isn't going to be bothered either way with that but the ESP8266 will take a few seconds each time it comes back on to connect up and be ready, and there is a greater chance of things going wrong whilst it tries to reconnected, which involves a bit more work each time.
What you really want to do is use the watchdog timer, this is a common method of protecting micro-controllers/computers from locking up should the code cause a problem. This will cover most eventualities. See ESP8266: Watchdog functions - techtutorialsx
I'm not sure how effective WiFimulti is in handling many WiFi routers, and connecting to the strongest access point is tricky for even more powerful devices, as it's not just about the strongest signal. All you can do is give it a try.