This Arduino library is improving the usage ESP32 WiFi module. The change log of this library can be found in CHANGELOG.md.
The library provides simple WiFi connection management. On the first launch, WiFiManager creates a Wi-Fi Access Point to setup a future connection to an existing Wi-Fi network. After checking connection, WiFiManager will save this configutation and restart the CPU. Next, WiFiManager will automatically connect to the saved Wi-Fi network, as well as periodically check the connection with the gateway (router). If the ping fails, a reconnect should occur.
To get the setup web page after connecting to the configuration Access Point, use http://192.168.4.1 in a browser. If DNS is enabled (default), it is also possible to redirect any http://xxx.xxx (httpS doesn't redirect!) address to the configuration portal.
On the configuration web page, you can select the Wi-Fi networks that were found.
In order to use memory efficiently WiFiManager uses some low-level ESP32 API calls (nvs, ping, httpd_server). WiFiManagerClass is only used as a wrapper for user-friendly interface, making it easy to access c-callback API functions.
Many ideas are used from the project s60sc/ESP32-CAM_MJPEG2SD.
Copy the files src/WiFiManager.cpp and src/WiFiManager.h to your project directory.
#include <Arduino.h>
#include "WiFiManager.h"
Some features can be configured with the -Dxxx compiler option (see platformio.ini)
#define WFM_ST_MDNS_ENABLE 1 // station mDNS service "http://%HOSTNAME%.local" - DISABLED BY DEFAULT
#define WFM_AP_DNS_ENABLE 1 // access point DNS service - ENABLED BY DEFAULT
#define WFM_SHOW_LOG // show debug messages over serial port - DISABLED BY DEFAULT
// default ip = "192.168.0.200"
// subnet = "255.255.255.0"
// gateway = router ip
// dns1 = router ip
WiFiManager.setStaticIP();
// or set the desired parameters
WiFiManager.setStaticIP("192.168.0.123");
If setStaticIP()
is not called, the IP address set by the router DHCP.
WiFiManager.configAP("my_ap_ssid", "123456789");
If configAP()
is not called, the default access point name "ESP-XXXX" is used, where XXXX is the end MAC address of the device, with an empty password (open).
WiFiManager.start(); // start with default Hostname = Access Point name
WiFiManager.start("esp_hostname"); // or set Hostname and start
WiFiManager.isConnected(); // if true - connection OK
WiFiManager.cleanWiFiAuthData();
WiFiManager.debugMemory("debugMemory");
This repository made as a Platformio project. See src/main.cpp for an example of usage.