WiFi backup connection

Is it possible to add a fault-back connection to another SSID (router)?
If not, please consider to add in the future. It will give more reliable connections, especially when develop security apps.

@SCH please describe in more detail what you are thinking about.

See this example that is included in the recent ESP8266 Arduino Core…

 *  This sketch trys to Connect to the best AP based on a given list

#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>

ESP8266WiFiMulti wifiMulti;

void setup() {
    wifiMulti.addAP("ssid_from_AP_1", "your_password_for_AP_1");
    wifiMulti.addAP("ssid_from_AP_2", "your_password_for_AP_2");
    wifiMulti.addAP("ssid_from_AP_3", "your_password_for_AP_3");

	Serial.println("Connecting Wifi...");
    if(wifiMulti.run() == WL_CONNECTED) {
        Serial.println("WiFi connected");
        Serial.println("IP address: ");

void loop() {
    if(wifiMulti.run() != WL_CONNECTED) {
        Serial.println("WiFi not connected!");

The situation is, when not able to connect to local Router, I may be using my neighbors Router. My code should be able to detect low RSSI and automatically switch to next SSID in list with highest RSSI. Can it be done?
I see in your code you can use wifiMulti. How does this works?

Anything can be done with enough effort.

Blynk already provides Provisioning so it’s really up to you to select the router.

the wifimulti example provided by @mikekgr works ok, i also use for several months.

you should set up blynk for manual config, than you can use wifimulti. i’m on phone right now, but if you wish i can provide tested code for implementing wifimulti + blynk later.

1 Like

please :smiley:

this code is for sonoff (esp82xx), but feel free to adjust to your hw:

void wifiSelector()
  wifiMulti.addAP("ssid1", "pwd 1");
  wifiMulti.addAP("ssid 2", "");
  wifiMulti.addAP("ssid 3", "");
  wifiMulti.addAP("ssid etc", "");

  unsigned long startWiFi = millis();

  while (wifiMulti.run() != WL_CONNECTED) {          // connect to the strongest of the networks above
    digitalWrite(LED_BLUE, ON);  // blue led on sonoff is active low!
    digitalWrite(LED_BLUE, OFF);

    if (millis() > startWiFi + WIFI_TIMEOUT) {
      //Serial.println("\tNo WiFi. ");

check blynk function - by @Costas (you should also call this with timer in main loop, say every 25-30 seconds):

void checkBlynk()
  if (wifiMulti.run() == WL_CONNECTED) {
    unsigned long startConnecting = millis();

    while (!Blynk.connected()) {

      if (millis() > startConnecting + SERVER_TIMEOUT) {
        //Serial.print("\tUnable to connect to server. ");

  //if (WiFi.status() != 3) Serial.print("\tNo WiFi. ");
  //Serial.printf("\tChecking again in %is.\n", BLYNK_CONNECTION_INTERVAL / 1000);

and the setup function:

void setup()
  //ArduinoOTA.setPassword((const char *)"123");     // no authentication by default

  wifiSelector();                                    // set wifi network

  digitalWrite(LED_BLUE, ON);                        // signal with solid blue the begin of blynk connect
  Blynk.config(auth, server);
  digitalWrite(LED_BLUE, OFF);                       // when the blue led is off, the device is connected to blynk server

1 Like

Thank you for informative info @wanek
I’ll give it a try :wink: