wifi-scan.ino

Arduino UNO R4 WiFi · File : wifi-scan.ino · Language : Arduino · Use case : Analyser les réseaux Wi-Fi et se connecter au cloud via l'ESP32-S3

The R4 WiFi Wi-Fi runs on a companion ESP32-S3: the ESP-style WiFi.h library provides scanning and connection. The script lists networks with their strength then prints the obtained IP — the basis of connected projects.

Hardware

An Arduino UNO R4 WiFi (Renesas RA4M1 @ 14 MHz + companion ESP32-S3 Wi-Fi/BLE, 12x8 LED matrix, RGB LED) powered by USB or 6-24 V. A 2.4 GHz access point (the radio cannot see 5 GHz).

Wiring

Nothing to wire. Antenna: avoid metal enclosures that kill the signal.

How it works

WiFi.scanNetworks enumerates SSIDs and RSSIs seen by the ESP32-S3; WiFi.begin associates the board and WiFi.localIP returns the address from the router.

Running it

Arduino IDE 2.x with the « Arduino UNO R4 Boards » core, « Arduino UNO R4 WiFi » board, serial port then Upload. The ESP32-S3 coprocessor updates separately if the IDE asks.

Variants

Build an HTTP client (WiFiClient + print) toward an API, or show signal quality on the LED matrix.

wifi-scan.ino

// Le R4 WiFi embarque un ESP32-S3 dedie au Wi-Fi : WiFi.h.
#include <WiFi.h>

const char *SSID = "votre-ssid";
const char *PASS = "votre-cle";

void setup() {
  Serial.begin(9600);
  delay(2000);

  int reseaux = WiFi.scanNetworks();
  Serial.print(F("reseaux trouves: "));
  Serial.println(reseaux);
  for (int i = 0; i < reseaux && i < 8; i++) {
    Serial.print(WiFi.RSSI(i));
    Serial.print(F(" dBm  "));
    Serial.println(WiFi.SSID(i));
  }

  WiFi.begin(SSID, PASS);
  Serial.println(F("connexion..."));
  unsigned long t0 = millis();
  while (WiFi.status() != WL_CONNECTED && millis() - t0 < 20000) delay(200);

  if (WiFi.status() == WL_CONNECTED) {
    Serial.print(F("IP: "));
    Serial.println(WiFi.localIP());
  } else {
    Serial.println(F("echec : verifier SSID/cle (2,4 GHz uniquement)"));
  }
}

void loop() {
  // Le coprocesseur Wi-Fi reste alimente meme en deep-sleep du RA4M1.
}

← Back to the board