point-acces.ino

Arduino Nano ESP32 · File : point-acces.ino · Language : Arduino · Use case : Créer un point d'accès WiFi pour configurer la carte

With no network available, the Nano ESP32 becomes its own access point: a phone joining NanoESP32-Config opens the settings page hosted on the board. The standalone-product configuration pattern in 40 lines.

Hardware

An Arduino Nano ESP32 (dual-core ESP32-S3, 2.4 GHz Wi-Fi + Bluetooth Low Energy, Nano-compatible physical pinout, native USB, 3.3 V pins only). Bare Nano ESP32, a phone or laptop to join it.

Wiring

No wiring; the AP appears with a fixed 192.168.4.1 IP on the board side.

How it works

WiFi.softAP starts the WPA2 beacon; WebServer handles GET/POST with lambda handlers. handleClient() in loop() serves one request per pass — enough for configuration.

Running it

Install the Arduino ESP32 Boards package (or follow the official Nano ESP32 guide), select Arduino Nano ESP32, upload. Pins are 3.3 V: never feed 5 V into an input. The serial monitor uses native USB.

Variants

Auto-switch to AP when the main network fails 3 times, or serve a page including the WiFi scan so users pick their SSID.

point-acces.ino

// Mode point d'acces : la Nano ESP32 devient elle-meme le routeur.
// Utile pour la configuration ou l'usage sans infrastructure.
#include <WiFi.h>
#include <WebServer.h>

WebServer serveur(80);
const char AP_SSID[] = "NanoESP32-Config";
const char AP_PASS[] = "config1234"; // WPA2, min 8 caracteres

void setup() {
  Serial.begin(115200);
  WiFi.mode(WIFI_AP);
  WiFi.softAP(AP_SSID, AP_PASS);
  Serial.print(F("AP "));
  Serial.print(AP_SSID);
  Serial.print(F(" — IP "));
  Serial.println(WiFi.softAPIP()); // typiquement 192.168.4.1

  serveur.on("/", []() {
    serveur.send(200, "text/html",
      "<h3>Nano ESP32</h3>"
      "<form method='POST' action='/reglages'>"
      "Seuil <input name='seuil' value='512'>"
      "<button>Enregistrer</button></form>");
  });
  serveur.on("/reglages", HTTP_POST, []() {
    int seuil = serveur.arg("seuil").toInt();
    Serial.println("seuil=" + String(seuil));
    serveur.send(200, "text/plain", "enregistre");
  });
  serveur.begin();
}

void loop() { serveur.handleClient(); }

← Back to the board