AyresWiFiManager is a library for ESP32 that allows configuring WiFi credentials and custom parameters through a local captive portal – ideal for IoT environments like alarms, automation, and smart devices.
Compatible with PlatformIO and Arduino IDE.
Open source, modular, and easy to integrate into any ESP32 project.
.
├── lib/
│ └── wifimanager/
│ ├── wifimanager.cpp
│ └── wifimanager.h
├── data/
│ └── wifimanager/
│ ├── index.html
│ ├── success.html
│ └── error.html
├── src/
│ └── main.cpp
├── platformio.ini
└── README_en.md
- 🔌 Auto-connects to known WiFi networks
- 🌐 Local captive portal when no network is configured
- 💾 HTML/CSS/JS served from LittleFS
- ⚙️ Supports custom parameters (e.g., MQTT, tokens, etc.)
- 🧰 Compatible with PlatformIO and Arduino IDE
- 📲 Ideal for headless systems (no screen required)
/wifimanager-esp32
├── src/
│ ├── WifiManager.cpp
│ └── WifiManager.h
├── data/
│ └── wifimanager/
│ ├── index.html
│ ├── style.css
│ └── script.js
├── examples/
│ ├── ejemplo_basico/
│ │ └── ejemplo_basico.ino
│ └── ejemplo_platformio/
│ └── ejemplo.cpp
├── library.json
├── library.properties
├── README_en.md
└── LICENSE
-
Add this to your
platformio.ini
:lib_deps = https://github.com/ayresnet/wifimanager-esp32
-
Upload web files from
/data
to ESP32 flash:pio run --target uploadfs
-
Flash your main code:
pio run --target upload
-
Download this repo as ZIP and add it via:
Sketch → Include Library → Add .ZIP Library
. -
Install the plugin ESP32 Sketch Data Upload to upload HTML files to the device.
-
Place your web portal files in:
/data/wifimanager/
-
Upload them via:
Tools → ESP32 Sketch Data Upload
#include <WifiManager.h>
#include <LittleFS.h>
#include <WiFi.h>
WifiManager wifiManager;
void setup() {
Serial.begin(115200);
delay(200);
// Initialize LittleFS (required to read wifi.json)
if (!LittleFS.begin()) {
Serial.println("❌ Failed to mount LittleFS");
return;
}
// Set the path where the captive portal HTML files are stored
wifiManager.setHtmlPathPrefix("/wifimanager/");
// Start WiFiManager (loads configuration from wifi.json if it exists)
wifiManager.begin();
// If wifi.json doesn't exist, launch the captive portal and halt execution
if (!LittleFS.exists("/wifi.json")) {
Serial.println("⚠️ wifi.json not found → starting captive portal");
wifiManager.run(); // AP mode – stays here until user configures
return;
}
// Attempt to connect using stored credentials
wifiManager.run();
// Check if the connection was successful
if (!wifiManager.isConnected()) {
Serial.println("❌ Failed to connect to WiFi");
return;
}
Serial.print("✅ Connected to: ");
Serial.println(WiFi.SSID());
}
void loop() {
wifiManager.update(); // keeps connection alive and handles events
}
This project is licensed under the MIT License – feel free to use, modify, and distribute it even for commercial use.
Contributions are welcome!
Open an Issue or submit a Pull Request to add improvements or fixes.
📄 Prefer to read this in Spanish? Visit README.es.md
Created by Daniel Cristian Salgado – AyresNet.