Use of Multiple SSID

I am trying to configure realtek based B&T BW16 board for multiple ssid and password for wifi connectivity. for example if first ssid is not connected or not available then it should try to connect second ssid. Unfortunately I couldn’t find any library for this. My question is that what would be the possible ways to achieve that in arduino ide code?.

Hi @zakriyazahid ,

You may refer to the WiFi example - Connect with WPA to configure ssid and password for WiFi connection. You can create an array of ssid and password to perform reconnection while using the status variable to check for connection status.

Thank you.

Thank you for your assistance. Approach you suggested is definitely easy. Meanwhile I have implemented it in a similar way for two SSIDs.

void WifiSetup() {
WiFi.config(Ip, subnet, gateway);

WiFi.begin(ssid1, pass1);

// Try to connect to SSID 1
for (int i = 0; i < 10; i++) {
if (WiFi.status() == WL_CONNECTED) {
Serial.println(“Connected to WiFi through SSID 1”);
break;
}
delay(500); // Add a short delay to avoid hammering the WiFi module
}

// If not connected, try SSID 2
if (WiFi.status() != WL_CONNECTED) {
WiFi.begin(ssid2, pass2);
for (int i = 0; i < 10; i++) {
if (WiFi.status() == WL_CONNECTED) {
Serial.println(“Connected to WiFi through SSID 2”);
break;
}
delay(500); // Add a short delay to avoid hammering the WiFi module
}
}

// Check if connected to either SSID
if (WiFi.status() == WL_CONNECTED) {
Serial.print("IP Address: ");
Serial.println(WiFi.localIP());
} else {
Serial.println(“Failed to connect to WiFi”);
}
}

1 Like