scan-wifi.ino

Arduino MKR WiFi 1010 · File : scan-wifi.ino · Language : Arduino · Use case : Lister les réseaux WiFi environnants

The first reflex with a MKR WiFi 1010: scan the 2.4 GHz band. This sketch checks the WINC1500 module is alive, verifies firmware version, then lists every network with signal strength and encryption type. Ideal to pick a channel or spot an invisible SSID.

Hardware

An Arduino MKR WiFi 1010 (SAMD21 microcontroller, WINC1500 Wi-Fi module, no Bluetooth, USB or LiPo power on J6). A MKR WiFi 1010 and a USB cable; nothing else, the WiFi module is onboard.

Wiring

No wiring: the WINC1500 is internally wired to the SAMD21 over SPI, the antenna sits on the module.

How it works

WiFi.scanNetworks() sweeps the 14 channels and returns the network count; SSID/RSSI/encryptionType query the result. The firmware check avoids connection failures caused by stale firmware.

Running it

Install Arduino SAMD Boards and the WiFi101 library, select the board, upload. Wi-Fi runs on 2.4 GHz only: check that your access point is not 5 GHz only.

Variants

Re-run the scan every minute to follow an unstable network, or filter by RSSI threshold to show only usable networks.

scan-wifi.ino

// Scan des reseaux WiFi avec le module WINC1500 (bibliotheque WiFi101).
#include <SPI.h>
#include <WiFi101.h>

void setup() {
  Serial.begin(9600);
  while (!Serial);
  // Le WINC1500 est branche en interne : aucun brochage a faire
  if (WiFi.status() == WL_NO_MODULE) {
    Serial.println(F("Module WiFi absent !"));
    while (true);
  }
  String firmware = WiFi.firmwareVersion();
  if (firmware < "19.6.3")
    Serial.println(F("Firmware WiFi101 trop ancien, mettez a jour"));
  Serial.println(F("Scan en cours..."));
  int n = WiFi.scanNetworks();
  if (n < 0) { Serial.println(F("scan echoue")); return; }
  Serial.print(n);
  Serial.println(F(" reseaux trouves :"));
  for (int i = 0; i < n; i++) {
    Serial.print(i + 1);
    Serial.print(": ");
    Serial.print(WiFi.SSID(i));
    Serial.print(" (");
    Serial.print(WiFi.RSSI(i));
    Serial.print(" dBm) ");
    Serial.println(WiFi.encryptionType(i) == ENC_TYPE_NONE
                   ? "ouvert" : "protege");
  }
}

void loop() {}

← Back to the board