The use of the ESP8266 in the world of IoT

User avatar
By Fabri54
#90802 Hi everybody,

I'm currently building a few smart plugs based on the tiny module ESP8266-01S, two relays and a power supply. It connects to the home WiFi network and it's seen by Alexa that can command the two relays.
The whole thing works fine with ESP8266WiFi but I need to add the capability of connecting to the strongest AP at home (I have three).
Unfortunately not even the WiFiMulti.ino basic example works. The ESP8266-01S starts looping without connecting to anything.
Please note that if I upload the usual WiFiScan.ino example it works fine and sees the 6-7 SSID I've around.
Has anybody a suggestion about what to do? I've seen, on Internet, that the WiFiMulti seems to have been problematic on 8266 but the subject is old and I haven't found any solution .
Many thanks in advance for any help
User avatar
By Fabri54
#90850 I thought it wasn't necessary because I'm using the example files which come with the installation of the ESP8266 board.
The one I'm mentioning is WiFiMulti.ino, here below
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 ( == WL_CONNECTED) {
Serial.println("WiFi connected");
Serial.println("IP address: ");

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