Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
W

WiFiManager

> 编程语言
Open source

ESP8266 WiFi Connection manager with web captive portal

7.2K stars0 likes2 views
WebsiteGitHub

About

ESP8266 WiFi Connection manager with web captive portal

WiFiManager

Espressif ESPx WiFi Connection manager with fallback web configuration portal

:warning: This Documentation is out of date, see notes below

Member to Member Support / Chat The configuration portal is of the captive variety, so on various devices it will present the configuration dialogue as soon as you connect to the created access point.

Works with the ESP8266 Arduino and ESP32 Arduino platforms.

Known Issues

  • Documentation needs to be updated, see https://github.com/tzapu/WiFiManager/issues/500

Contents

  • How it works
  • Wishlist
  • Quick start
    • Installing
      • Arduino - Through Library Manager
      • Arduino - From Github
      • PlatformIO
    • Using
  • Documentation
    • Access Point Password
    • Callbacks
    • Configuration Portal Timeout
    • On Demand Configuration
    • Custom Parameters
    • Custom IP Configuration
    • Filter Low Quality Networks
    • Debug Output
  • Troubleshooting
  • Releases
  • Contributors

How It Works

  • When your ESP starts up, it sets it up in Station mode and tries to connect to a previously saved Access Point
  • if this is unsuccessful (or no previous network saved) it moves the ESP into Access Point mode and spins up a DNS and WebServer (default ip 192.168.4.1)
  • using any wifi enabled device with a browser (computer, phone, tablet) connect to the newly created Access Point
  • because of the Captive Portal and the DNS server you will either get a 'Join to network' type of popup or get any domain you try to access redirected to the configuration portal
  • choose one of the access points scanned, enter password, click save
  • ESP will try to connect. If successful, it relinquishes control back to your app. If not, reconnect to AP and reconfigure.
  • There are options to change this behavior or manually start the configportal and webportal independantly as well as run them in non blocking mode.

How It Looks

Wishlist

  • remove dependency on EEPROM library
  • move HTML Strings to PROGMEM
  • cleanup and streamline code (although this is ongoing)
  • if timeout is set, extend it when a page is fetched in AP mode
  • add ability to configure more parameters than ssid/password
  • maybe allow setting ip of ESP after reboot
  • add to Arduino Library Manager
  • add to PlatformIO
  • add multiple sets of network credentials
  • allow users to customize CSS
  • rewrite documentation for simplicity, based on scenarios/goals

Development

  • ESP32 support
  • rely on the SDK's built in auto connect more than forcing a connect
  • add non blocking mode
  • easy customization of strings
  • hostname support
  • fix various bugs and workarounds for esp SDK issues
  • additional info page items
  • last status display / faiilure reason
  • customizeable menu
  • seperate custom params page
  • ondemand webportal
  • complete refactor of code to segment functions
  • wiif scan icons or percentage display
  • invert class for dark mode
  • more template tokens
  • progmem for all strings
  • new callbacks
  • new callouts / filters
  • shared web server instance
  • latest esp idf/sdk support
  • wm is now non persistent, will not erase or change stored esp config on esp8266
  • tons of debugging output / levels
  • disable captiveportal
  • preload wiifscans, faster page loads
  • softap stability fixes when sta is not connected

Quick Start

Installing

You can either install through the Arduino Library Manager or checkout the latest changes or a release from github

Install through Library Manager

Currently version 0.8+ works with release 2.4.0 or newer of the ESP8266 core for Arduino

  • in Arduino IDE got to Sketch/Include Library/Manage Libraries

  • search for WiFiManager

  • click Install and start using it

Checkout from github

Github version works with release 2.4.0 or newer of the ESP8266 core for Arduino

  • Checkout library to your Arduino libraries folder

Using

  • Include in your sketch
cpp
#include <WiFiManager.h>          //https://github.com/tzapu/WiFiManager WiFi Configuration Magic
  • Initialize library, in your setup function add, NOTEif you are using non blocking you will make sure you create this in global scope or handle appropriatly , it will not work if in setup and using non blocking mode.
cpp
WiFiManager wifiManager;
  • Also in the setup function add
cpp
//first parameter is name of access point, second is the password
wifiManager.autoConnect("AP-NAME", "AP-PASSWORD");

if you just want an unsecured access point

cpp
wifiManager.autoConnect("AP-NAME");

or if you want to use and auto generated name from 'ESP' and the esp's Chip ID use

cpp
wifiManager.autoConnect();

After you write your sketch and start the ESP, it will try to connect to WiFi. If it fails it starts in Access Point mode. While in AP mode, connect to it then open a browser to the gateway IP, default 192.168.4.1, configure wifi, save and it should reboot and connect.

Also see examples.

Install Using PlatformIO

PlatformIO is an emerging ecosystem for IoT development, and is an alternative to using the Arduino IDE. Install WiFiManager using the platformio library manager in your editor, or using the PlatformIO Core CLI, or by adding it to your platformio.ini as shown below (recommended approach).

The simplest way is to open the platformio.ini file at the root of your project, and WifiManager to the common top-level env lib_deps key like so:

[env]
lib_deps =
	WiFiManager
[env]
lib_deps =
	https://github.com/tzapu/WiFiManager.git

Documentation

Switch languages for the configuration website

You can switch the language for configuration website during compile time. Default is LANG_EN for an english setup. Within PlatformIO add the following compile parameter:

ini
[env]
build_flags = -D LANG_EN

Currently the following language codes are available:

ini
LANG_DE
LANG_EN
LANG_ES
LANG_FR
LANG_PT
LANG_PT_BR

Password protect the configuration Access Point

You can and should password protect the configuration access point. Simply add the password as a second parameter to autoConnect. A short password seems to have unpredictable results so use one that's around 8 characters or more in length. The guidelines are that a wifi password must consist of 8 to 63 ASCII-encoded characters in the range of 32 to 126 (decimal)

cpp
wifiManager.autoConnect("AutoConnectAP", "password")

Callbacks

Enter Config mode

Use this if you need to do something when your device enters configuration mode on failed WiFi connection attempt. Before autoConnect()

cpp
wifiManager.setAPCallback(configModeCallback);

configModeCallback declaration and example

cpp
void configModeCallback (WiFiManager *myWiFiManager) {
  Serial.println("Entered config mode");
  Serial.println(WiFi.softAPIP());

  Serial.println(myWiFiManager->getConfigPortalSSID());
}
Save settings

This gets called when custom parameters have been set AND a connection has been established. Use it to set a flag, so when all the configuration finishes, you can save the extra parameters somewhere.

IF YOU NEED TO SAVE PARAMETERS EVEN ON WIFI FAIL OR EMPTY, you must set setBreakAfterConfig to true, or else saveConfigCallback will not be called.

cpp
//if this is set, it will exit after config, even if connection is unsuccessful.
    void          setBreakAfterConfig(boolean shouldBreak);

See AutoConnectWithFSParameters Example.

cpp
wifiManager.setSaveConfigCallback(saveConfigCallback);

saveConfigCallback declaration and example

cpp
//flag for saving data
bool shouldSaveConfig = false;

//callback notifying us of the need to save config
void saveConfigCallback () {
  Serial.println("Should save config");
  shouldSaveConfig = true;
}

Configuration Portal Timeout

If you need to set a timeout so the ESP doesn't hang waiting to be configured, for instance after a power failure, you can add

cpp
wifiManager.setConfigPortalTimeout(180);

which will wait 3 minutes (180 seconds). When the time passes, the autoConnect function will return, no matter the outcome. Check for connection and if it's still not established do whatever is needed (on some modules I restart them to retry, on others I enter deep sleep)

On Demand Configuration Portal

If you would rather start the configuration portal on demand rather than automatically on a failed connection attempt, then this is for you.

Instead of calling autoConnect() which does all the connecting and failover configuration portal setup for you, you need to use startConfigPortal(). Do not use BOTH.

Example usage

cpp
void loop() {
  // is configuration portal requested?
  if ( digitalRead(TRIGGER_PIN) == LOW ) {
    WiFiManager wifiManager;
    wifiManager.startConfigPortal("OnDemandAP");
    Serial.println("connected...yeey :)");
  }
}

See example for a more complex version. OnDemandConfigPortal

Exiting from the Configuration Portal

Normally, once entered, the configuration portal will continue to loop until WiFi credentials have been successfully entered or a timeout is reached. If you'd prefer to exit without joining a WiFi network, say becuase you're going to put the ESP into AP mode, then press the "Exit" button on the main webpage. If started via autoConnect or startConfigPortal then it will return false (portalAbortResult)

Custom Parameters

You can use WiFiManager to collect more parameters than just SSID and password. This could be helpful for configuring stuff like MQTT host and port, blynk or emoncms tokens, just to name a few. You are responsible for saving and loading these custom values. The library just collects and displays the data for you as a convenience. Usage scenario would be:

  • load values from somewhere (EEPROM/FS) or generate some defaults
  • add the custom parameters to WiFiManager using
cpp
 // id/name, placeholder/prompt, default, length
 WiFiManagerParameter custom_mqtt_server("server", "mqtt server", mqtt_server, 40);
 wifiManager.addParameter(&custom_mqtt_server);
  • if connection to AP fails, configuration portal starts and you can set /change the values (or use on demand configuration portal)
  • once configuration is done and connection is established save config callback() is called
  • once WiFiManager returns control to your application, read and save the new values using the WiFiManagerParameter object.
cpp
 mqtt_server = custom_mqtt_server.getValue();

This feature is a lot more involved than all the others, so here are some examples to fully show how it is done. You should also take a look at adding custom HTML to your form.

  • Save and load custom p

Issues· 672 open

View all issuesOpen on GitHub
  • #1121

    WM with ESPAsyncWebserver

    enhancementDEV Help WantedIn ProgressBranchUpdated Sep 28, 2026
  • #1873

    Proposal: v3 async portal migration path — translations and a defined compatibility boundary

    Updated Sep 28, 2026
  • #1268

    it is possible to change MAC address with WiFi manager?

    Updated Sep 21, 2026
  • #1410

    Can I use it with ESPAsyncWebServer?

    QuestionUpdated Sep 9, 2026
  • #1498

    WIFI List not Scrollable

    In ProgressGood First Issue:spider_web: HTTPUpdated Aug 6, 2026
  • #1870

    Wifi connection

    Updated Jul 11, 2026
  • #1869

    Creating a unique AP SSID

    Updated Jul 2, 2026
  • #842

    Adding logo to the WifiManager config portal page...

    DEV Help WantedQuestionUpdated Jun 22, 2026
  • #1867

    5GHz issue

    Updated Jun 7, 2026
  • #1868

    feature request

    Updated Jun 6, 2026

> Tags

C++arduinocaptiveconfiguration-portalesp8266

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedOct 2, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言