A robust and user-friendly Arduino library for the ESP32 to manage WiFi connections. It provides a non-blocking web portal for on-the-fly configuration, allowing you to change WiFi credentials and operating modes without needing to re-flash the device.
The entire process runs as an independent task on a separate core, ensuring your main application code remains responsive and free from network-related delays.
Web-Based Configuration: No more hard-coded WiFi credentials. Configure everything from a web browser on your phone or laptop.
Dual Mode Operation: Easily switch between:
Station (STA) Mode: Connect the ESP32 to an existing WiFi network.
Access Point (AP) Mode: The ESP32 creates its own WiFi network for other devices to connect to.
Persistent Storage: All settings (mode, SSID, password) are saved permanently to the ESP32's non-volatile flash memory using the
Preferenceslibrary.Truly Non-Blocking: The entire WiFi connection and web server logic runs as a dedicated FreeRTOS task on a separate core. Your
loop()function is never blocked.Manual Reconfiguration Trigger: You can force the device into configuration mode at any time by simply holding down the onboard BOOT button for a few seconds.
Automatic Captive Portal: When in configuration mode, connecting to the ESP32's network will automatically open the configuration page on most devices.
The library is designed to be extremely simple to integrate into your projects.
#include "WiFiConfigManager.h"// Create an instance of the manager WiFiConfigManager wifiManager;
// Pin for the manual trigger (GPIO 0 is the BOOT button) const int TRIGGER_PIN = 0;
void setup() { Serial.begin(115200); pinMode(TRIGGER_PIN, INPUT_PULLUP);
// This single function starts the WiFi manager in the background on Core 0. // It will attempt to connect using saved credentials. If it fails, // it will automatically start the configuration portal. wifiManager.beginAndRunInBackground(0); }
void loop() { // Your main application code runs here on Core 1, completely // unaffected by the WiFi management task.
// You can check the button to manually enter config mode if (digitalRead(TRIGGER_PIN) == LOW) { // Logic to detect a long press... // If pressed long enough: // wifiManager.startConfigPortalBlocking(); }
// Example: Print status if(WiFi.status() == WL_CONNECTED) { // Do something when connected }
delay(1000); }
First Boot / Failed Connection: If the ESP32 has no saved credentials or fails to connect, it will create its own WiFi network (e.g.,
"ESP32-Setup").Connect to the Portal: Use your phone or laptop to connect to this new WiFi network.
Automatic Redirect: A captive portal should automatically open the configuration page in your browser. If not, open a browser and navigate to any address (e.g.,
192.168.4.1).Configure & Save: Choose the desired mode (Station or AP), enter the credentials, and click "Save & Restart".
Restart & Run: The ESP32 will save the configuration and restart. It will then automatically operate in the mode you selected.