WiFi.scanNetworks() limits list to 10

Hello all. I’ve been stumbling on this for a while.

I am testing a MKR WiFi 1010 in an environment that has a lot of Wifi networks (i.e. 25+). I noticed that WiFi.scanNetworks() keeps returning only first 10 networks it finds.

To further test that I wrote the simple code below, which loops through the scans and prints the result to the serial monitor. Indeed every time I only get 10 networks (SSID number 0 - 9) and btw the list keeps changing (unclear how the networks are ranked, maybe signal strength or else). I tried to look into the documentation but I haven’t found anything specifying this limitation.

I’ll pass along the code, but I don’t think there is anything odd here that would prevent having a list bigger than 10 items. Maybe it’s in one of the library or else.

Any idea?

#include <SPI.h>
#include <WiFiNINA.h>

void setup() {
  // Open serial
  Serial.begin(9600);
  while (!Serial) {
  }

  // WiFi module?
  if (WiFi.status() == WL_NO_MODULE) {
    Serial.println("No Wifi Module");
    while (true);
  }
  
  // Latest Firmware?
  String fv = WiFi.firmwareVersion();
  if (fv < WIFI_FIRMWARE_LATEST_VERSION) {
    Serial.println("Old Firmware");
  }

}

void loop () {
  Serial.println("------------------------------");
  Serial.println("Scanning...");
  scanForWiFis();
  delay(5000);
}

void scanForWiFis() {
  int numberOfWiFi = WiFi.scanNetworks();
  Serial.print("WiFi Networks Found:");
  Serial.println(numberOfWiFi);
  for (int i = 0; i<numberOfWiFi; i++) {
    Serial.print(i);
    Serial.print("- ");
    Serial.println(WiFi.SSID(i));
  }
}

There is a limit set in the WiFiNINA library. The library folder is in your project folder.

Have a look into the wl_definitions.h file.

// Maximum size of a SSID list
#define WL_NETWORKS_LIST_MAXNUM 10

There might be a reason why this was set. So, change at your own risk and test everything. There might be other things you need to change e.g some buffer ...

Thanks. I had a gut feeling there was a limit somewhere but couldn't find it. Also good advice; now that I am certain of the limit I can work around it without modifying that max value. Thanks again.