WIFiMulti library doesen't work

I’m trying to use the WiFiMulti example from the Seeed_Arduino_atWiFi library, but I always get this error on the serial monitor even if I insert only one available ssid.
[E] [WiFiMulti.cpp: 189] run (): [WIFI] Connecting Failed (255).
I think it’s too short a timeout problem.
Has anyone had the same problem?
How did you solve it?

I did a test to check if it was a timeout problem and in fact if I modify the code in this way it works, but the solution is not clean and I don’t like it very much. can you do something about the library?
This sketch trys to Connect to the best AP based on a given list


#include “AtWiFi.h”
#include <WiFiMulti.h>

WiFiMulti wifiMulti;

void setup() {

wifiMulti.addAP("AAR-GUEST", "******");
wifiMulti.addAP("Area Wifi", "******");
wifiMulti.addAP("D-Link-GR 2.4 Gz", "*******");

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!”);

This is the serial monitor
Connecting Wifi…
[E][WiFiMulti.cpp:189] run(): [WIFI] Connecting Failed (255).

WiFi connected
IP address:

hi Gianfry60,
We tested the WiFiMulti example.
Run() report error when the first time, but will connect success after a while.
That’s not a timeout problem, it really need time to connect WiFi AP.

Hi @turmary, I also did the tests but the routine works correctly only if I enter the wifiMulti.run () command twice. The first does not solve the sequence, the second is successful. Keep in mind that to do this test I entered three AP addresses and the first two are not reachable. For now I have solved this way but I do not understand why it is not successful the first time. if you need me to do test reports, tell me what to do.
Thank you