[GH-ISSUE #1375] Auto toggle between Autoconnect and AP? #1179

Closed
opened 2026-02-28 01:28:52 +03:00 by kerem · 3 comments
Owner

Originally created by @Abhesheksh on GitHub (Mar 23, 2022).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1375

Basic Infos

Hardware

WiFimanager Branch/Release: Master

Esp8266/Esp32: ESP8266

Hardware: ESP-12e, esp01, esp25

ESP12E

Core Version: 2.4.0, staging

Description

In my case, the internet connection can go off for as long as 30-60 minutes, sometimes even more. Right now, after failing to connect, the ESP goes to AP mode and remains in AP mode forever. However, I would like it to change between AP mode and Autoconnect mode every 5-10 minutes. This is my relevant code right now below. What values should I use in setConfigPortalTimeout & setConnectTimeout to implement this?

WiFi.mode(WIFI_STA);

wifiManager.setConfigPortalTimeout(300);
wifiManager.setConnectTimeout(600);

wifiManager.setWiFiAPHidden(false);
//wifiManager.setSTAStaticIPConfig(IPAddress(192, 168, 1, 99), IPAddress(192, 168, 1, 1), IPAddress(255, 255, 255, 0));
wifiManager.autoConnect("ESP_WIFI_AP");

if (wifiManager.autoConnect("ESP_WIFI_AP") == true)
{
Serial.println("Conneted to Internet");
ticker.detach();
digitalWrite(LED, LOW);

}
else
{
Serial.println("Connection Lost");
send_email();
}

Settings in IDE

Module: NodeMcu, Wemos D1
NodeMCU

Additional libraries:

#include <Ticker.h>
#include <ESP8266WiFi.h>
#include "ESP8266Ping.h"
#include <WiFiManager.h>
#include <EasyButton.h>
#include <NTPClient.h>
#include <WiFiUdp.h>

Originally created by @Abhesheksh on GitHub (Mar 23, 2022). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1375 ### Basic Infos #### Hardware WiFimanager Branch/Release: Master Esp8266/Esp32: ESP8266 Hardware: ESP-12e, esp01, esp25 ESP12E Core Version: 2.4.0, staging ### Description In my case, the internet connection can go off for as long as 30-60 minutes, sometimes even more. Right now, after failing to connect, the ESP goes to AP mode and remains in AP mode forever. However, I would like it to change between AP mode and Autoconnect mode every 5-10 minutes. This is my relevant code right now below. What values should I use in setConfigPortalTimeout & setConnectTimeout to implement this? WiFi.mode(WIFI_STA); wifiManager.setConfigPortalTimeout(300); wifiManager.setConnectTimeout(600); wifiManager.setWiFiAPHidden(false); //wifiManager.setSTAStaticIPConfig(IPAddress(192, 168, 1, 99), IPAddress(192, 168, 1, 1), IPAddress(255, 255, 255, 0)); wifiManager.autoConnect("ESP_WIFI_AP"); if (wifiManager.autoConnect("ESP_WIFI_AP") == true) { Serial.println("Conneted to Internet"); ticker.detach(); digitalWrite(LED, LOW); } else { Serial.println("Connection Lost"); send_email(); } ### Settings in IDE Module: NodeMcu, Wemos D1 NodeMCU Additional libraries: #include <Ticker.h> #include <ESP8266WiFi.h> #include "ESP8266Ping.h" #include <WiFiManager.h> #include <EasyButton.h> #include <NTPClient.h> #include <WiFiUdp.h>
kerem closed this issue 2026-02-28 01:28:52 +03:00
Author
Owner

@Abhesheksh commented on GitHub (Mar 23, 2022):

So basically, when wifi credentials are saved in the ESP but the saved network is switched off, it tries to autoconnect for a while but then goes to AP mode forever despite setting wifiManager.setConfigPortalTimeout(300) to 5 minutes. How do I make the ESP come back from AP mode and try connecting to the wifi network again?

<!-- gh-comment-id:1076469253 --> @Abhesheksh commented on GitHub (Mar 23, 2022): So basically, when wifi credentials are saved in the ESP but the saved network is switched off, it tries to autoconnect for a while but then goes to AP mode forever despite setting wifiManager.setConfigPortalTimeout(300) to 5 minutes. How do I make the ESP come back from AP mode and try connecting to the wifi network again?
Author
Owner

@tablatronix commented on GitHub (Mar 23, 2022):

It should close the cp after 300 seconds, do you have logs?

<!-- gh-comment-id:1076529914 --> @tablatronix commented on GitHub (Mar 23, 2022): It should close the cp after 300 seconds, do you have logs?
Author
Owner

@Abhesheksh commented on GitHub (Mar 24, 2022):

I think its working now when I check it over Serial on NodeMCU. I will run the program on the actual PCB again and check.

<!-- gh-comment-id:1077820737 --> @Abhesheksh commented on GitHub (Mar 24, 2022): I think its working now when I check it over Serial on NodeMCU. I will run the program on the actual PCB again and check.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/WiFiManager#1179
No description provided.