I learned that the wifiMulti - library / function does automatically re-connect to another available WiFi-Network if the current, strongest WiFi-Network fails. All I have to do is set wifiMulit.run() in the void loop, according to this article.
But I have noticed that the alternative WiFi connection remains, even if the first, strongest WiFi network recovered.
To be sure my ESP8266 re-connects always to the strongest network, I wrote this code snippet (Arduino IDE) to reassure every houre to be connected to the strongest WiFi-Network:
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
void setup() {
...
startMillis = millis();
wifiMulti.addAP("1st", "xxx");
wifiMulti.addAP("2nt", "xxx");
wifiMulti.addAP("3rd", "xxx");
while (wifiMulti.run() != WL_CONNECTED) {
delay(1000);
}
}
void loop() {
...
currentMillis = millis();
if (currentMillis - startMillis > 3600000) {
while (WiFi.status() == WL_CONNECTED) {
WiFi.disconnect();
delay(1000);
}
while (wifiMulti.run() != WL_CONNECTED) {
delay(1000);
}
startMillis = millis();
}
...
}
Now, I noticed that this works some hours or days, but sometime it stops working for sure. There are suddenly no further re-connections.
Has anybode an idea what I'm doing wrong?
Regards
Roman