So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By RK_aus_S
#76528 Hi
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:

Code: Select all
#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
User avatar
By RK_aus_S
#76618 Maybe I formulated my question too cumbersome or complicated?

So, the question is, why does Wifi no longer connect if you loop a few times through these commands, e.g. once an houre?:

Code: Select allvoid loop() {
...
   while (WiFi.status() == WL_CONNECTED) {
      WiFi.disconnect();
      delay(1000);
   }
   while (wifiMulti.run() != WL_CONNECTED) {
      delay(1000);
   }
...
}


It stops reconnecting for sure. If I reset the ESP8266 it starts reconnecting a few hours an stops reconnecting again. As if something is running full or over?

I has absolutely no idea what's wrong. :?

Regards
Roman