gitmyhub

WiFiManager

C++ ★ 7.2k updated 3mo ago

ESP8266 WiFi Connection manager with web captive portal

An Arduino library for ESP8266 and ESP32 boards that handles WiFi setup through a browser-based portal. When the device can't connect to a known network, it creates a temporary hotspot so users can pick their network and enter credentials from any phone or laptop.

C++ArduinoESP8266ESP32setup: easycomplexity 2/5

WiFiManager is an Arduino library for ESP8266 and ESP32 microcontroller boards that solves a common problem with IoT devices: how do you configure the WiFi network without hardcoding the credentials into your code? The answer it provides is a fallback web interface that appears automatically when the device cannot connect to a known network.

Here is how it works in practice. When an ESP board running WiFiManager starts up, it tries to connect to whatever WiFi network it has previously saved. If that succeeds, your application takes over as normal. If it does not, the board switches into access point mode and creates its own small WiFi network. Any phone, laptop, or tablet that connects to that temporary network will be redirected to a configuration page in the browser, similar to hotel WiFi login pages. You select your home network from a scan list, type the password, and save it. The board stores the credentials, reconnects, and hands control back to your code.

This means you can distribute a device or move it to a new location without recompiling or reflashing. The configuration happens in the browser, not in code. There is no need to know the WiFi password ahead of time when building or shipping the device.

The library supports custom parameters beyond WiFi credentials, so you can collect other setup values like API keys or server addresses through the same portal. You can also protect the access point with a password, set a timeout so the portal closes after a period of inactivity, or trigger the portal on demand at runtime rather than only on failed connection.

Available through the Arduino Library Manager and PlatformIO, the library works with both ESP8266 and ESP32 chip families.

Where it fits