Does ScanNetworks work?

I have now tried 3 different MKR Wifi 1010 boards and not one of them shows a wifi network. An Arduino Uno with an ESP8266 Esp-01 board recognises the network.

Is there any trouble-shooting possible?

Has anyone had any success with these boards / sample code?

is that the sketch you tried? there are so many floating around

Make sure that your MKR Wifi 1010's WiFiNINA firmware is updated (see https://support.arduino.cc/hc/en-us/articles/360013896579-Check-and-update-the-firmware-for-WiFiNINA-and-WiFi101) and check the article shared by J-M-L

Yup, it is all good:

"WiFiNINA firmware check.

Firmware version installed: 1.4.8
Latest firmware version available : 1.4.8

Check result: PASSED"

1 Like

Sorry - missed your reply.

Yes, it is the same code.

As this is the third board which doesn't work, I suspect it is the setting on the router, but I have disabled 5GHz, set the 2.4GHz channel to Mode 3 (minimises functionality) and I get nothing, but all other devices sees my (and my neighbours) networks.

It is driving me crazy...

So, I have now tried four boards (1 from a new company to make sure the others weren't a bad batch). Still scanNetworks() returns 0. I have an Arduino and NodeMCU working fine and connecting to the wifi network.

I have also added some code to the listNetworks example:

void listNetworks() {
  // scan for nearby networks:
  Serial.println("** Scan Networks **");
  int numSsid = WiFi.scanNetworks();

    int status  = WiFi.status();
    Serial.print("Status : ");
    Serial.print(WiFi.status()); Serial.print(" : "); 
    
    if(status == WL_CONNECTED) {
    Serial.print("WL_CONNECTED");Serial.print(" : ");Serial.println(WL_CONNECTED);}
    if(status == WL_AP_CONNECTED){ Serial.print("WL_AP_CONNECTED");Serial.print(" : ");Serial.println(WL_AP_CONNECTED);}
    if(status == WL_AP_LISTENING){ Serial.print("WL_AP_LISTENING");Serial.print(" : ");Serial.println(WL_AP_LISTENING);}
    if(status== WL_NO_SHIELD){ Serial.print("WL_NO_SHIELD");Serial.print(" : ");Serial.println(WL_NO_SHIELD);}
    if(status == WL_NO_MODULE){ Serial.print("WL_NO_MODULE");Serial.print(" : ");Serial.println(WL_NO_MODULE);}
    if(status == WL_IDLE_STATUS){ Serial.print("WL_IDLE_STATUS");Serial.print(" : ");Serial.println(WL_IDLE_STATUS);}
    if(status == WL_NO_SSID_AVAIL){ Serial.print("WL_NO_SSID_AVAIL");Serial.print(" : ");Serial.println(WL_NO_SSID_AVAIL);}
    if(status== WL_SCAN_COMPLETED){ Serial.print("WL_SCAN_COMPLETED");Serial.print(" : ");Serial.println(WL_SCAN_COMPLETED);}
    if(status == WL_CONNECT_FAILED){ Serial.print("WL_CONNECT_FAILED");Serial.print(" : ");Serial.println(WL_CONNECT_FAILED);}
    if(status == WL_CONNECTION_LOST){ Serial.print("WL_CONNECTION_LOST");Serial.print(" : ");Serial.println(WL_CONNECTION_LOST);}
    if(status == WL_DISCONNECTED) {Serial.print("WL_DISCONNECTED");Serial.print(" : ");Serial.println(WL_DISCONNECTED);}

  
etc, etc

To give the status after WiFi.scanNetworks(); has been run.

The result is:

Status : 255 : WL_NO_SHIELD : 255
WL_NO_MODULE : 255

However, the check for WL_NO_MODULE in setup() does not find it.

The firmware has been flashed with the latest (1.5.0 in IDE 2).

Full code (only added feedback to try to understand what is going on:

/*
 This example  prints the board's MAC address, and
 scans for available WiFi networks using the NINA module.
 Every ten seconds, it scans again. It doesn't actually
 connect to any network, so no encryption scheme is specified.

 Circuit:
 * Board with NINA module (Arduino MKR WiFi 1010, MKR VIDOR 4000 and UNO WiFi Rev.2)

 created 13 July 2010
 by dlf (Metodo2 srl)
 modified 21 Junn 2012
 by Tom Igoe and Jaymes Dec
 */


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

void setup() {
  //Initialize serial and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // check for the WiFi module:
  if (WiFi.status() == WL_NO_MODULE) {
    Serial.println("Communication with WiFi module failed!");
    // don't continue
    while (true);
  }
    Serial.print("Status : ");
    Serial.print(WiFi.status()); Serial.print(" : "); 
    if(WiFi.status() == WL_CONNECTED) Serial.println("WL_CONNECTED");
    if(WiFi.status() == WL_AP_CONNECTED) Serial.println("WL_AP_CONNECTED");
    if(WiFi.status() == WL_AP_LISTENING) Serial.println("WL_AP_LISTENING");
    if(WiFi.status() == WL_NO_SHIELD) Serial.println("WL_NO_SHIELD");
    if(WiFi.status() == WL_NO_MODULE) Serial.println("WL_NO_MODULE");
    if(WiFi.status() == WL_IDLE_STATUS) Serial.println("WL_IDLE_STATUS");
    if(WiFi.status() == WL_NO_SSID_AVAIL) Serial.println("WL_NO_SSID_AVAIL");
    if(WiFi.status() == WL_SCAN_COMPLETED) Serial.println("WL_SCAN_COMPLETED");
    if(WiFi.status() == WL_CONNECT_FAILED) Serial.println("WL_CONNECT_FAILED");
    if(WiFi.status() == WL_CONNECTION_LOST) Serial.println("WL_CONNECTION_LOST");
    if(WiFi.status() == WL_DISCONNECTED) Serial.println("WL_DISCONNECTED");

  String fv = WiFi.firmwareVersion();
  if (fv < WIFI_FIRMWARE_LATEST_VERSION) {
    Serial.println("Please upgrade the firmware");
  }

  // print your MAC address:
  byte mac[6];
  WiFi.macAddress(mac);
  Serial.print("MAC: ");
  printMacAddress(mac);
}

void loop() {
  // scan for existing networks:
  Serial.println("Scanning available networks...");
  listNetworks();
  delay(10000);
}

void listNetworks() {
  // scan for nearby networks:
  Serial.println("** Scan Networks **");
  int numSsid = WiFi.scanNetworks();

    int status  = WiFi.status();
    Serial.print("Status : ");
    Serial.print(WiFi.status()); Serial.print(" : "); 
    
    if(status == WL_CONNECTED) {
    Serial.print("WL_CONNECTED");Serial.print(" : ");Serial.println(WL_CONNECTED);}
    if(status == WL_AP_CONNECTED){ Serial.print("WL_AP_CONNECTED");Serial.print(" : ");Serial.println(WL_AP_CONNECTED);}
    if(status == WL_AP_LISTENING){ Serial.print("WL_AP_LISTENING");Serial.print(" : ");Serial.println(WL_AP_LISTENING);}
    if(status== WL_NO_SHIELD){ Serial.print("WL_NO_SHIELD");Serial.print(" : ");Serial.println(WL_NO_SHIELD);}
    if(status == WL_NO_MODULE){ Serial.print("WL_NO_MODULE");Serial.print(" : ");Serial.println(WL_NO_MODULE);}
    if(status == WL_IDLE_STATUS){ Serial.print("WL_IDLE_STATUS");Serial.print(" : ");Serial.println(WL_IDLE_STATUS);}
    if(status == WL_NO_SSID_AVAIL){ Serial.print("WL_NO_SSID_AVAIL");Serial.print(" : ");Serial.println(WL_NO_SSID_AVAIL);}
    if(status== WL_SCAN_COMPLETED){ Serial.print("WL_SCAN_COMPLETED");Serial.print(" : ");Serial.println(WL_SCAN_COMPLETED);}
    if(status == WL_CONNECT_FAILED){ Serial.print("WL_CONNECT_FAILED");Serial.print(" : ");Serial.println(WL_CONNECT_FAILED);}
    if(status == WL_CONNECTION_LOST){ Serial.print("WL_CONNECTION_LOST");Serial.print(" : ");Serial.println(WL_CONNECTION_LOST);}
    if(status == WL_DISCONNECTED) {Serial.print("WL_DISCONNECTED");Serial.print(" : ");Serial.println(WL_DISCONNECTED);}

  
  if (numSsid == -1) {
    Serial.println("Couldn't get a WiFi connection");
    while (true);
  }

  // print the list of networks seen:
  Serial.print("number of available networks:");
  Serial.println(numSsid);

  // print the network number and name for each network found:
  for (int thisNet = 0; thisNet < numSsid; thisNet++) {
    Serial.print(thisNet);
    Serial.print(") ");
    Serial.print(WiFi.SSID(thisNet));
    Serial.print("\tSignal: ");
    Serial.print(WiFi.RSSI(thisNet));
    Serial.print(" dBm");
    Serial.print("\tEncryption: ");
    printEncryptionType(WiFi.encryptionType(thisNet));
  }
}

void printEncryptionType(int thisType) {
  // read the encryption type and print out the name:
  switch (thisType) {
    case ENC_TYPE_WEP:
      Serial.println("WEP");
      break;
    case ENC_TYPE_TKIP:
      Serial.println("WPA");
      break;
    case ENC_TYPE_CCMP:
      Serial.println("WPA2");
      break;
    case ENC_TYPE_NONE:
      Serial.println("None");
      break;
    case ENC_TYPE_AUTO:
      Serial.println("Auto");
      break;
    case ENC_TYPE_UNKNOWN:
    default:
      Serial.println("Unknown");
      break;
  }
}


void printMacAddress(byte mac[]) {
  for (int i = 5; i >= 0; i--) {
    if (mac[i] < 16) {
      Serial.print("0");
    }
    Serial.print(mac[i], HEX);
    if (i > 0) {
      Serial.print(":");
    }
  }
  Serial.println();
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.