mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-27 09:05:56 +03:00
[GH-ISSUE #1454] Connect to known SSID after a power failure? dont start a new access point. #1243
Labels
No labels
📶 WiFi
🕸️ HTTP
Branch
DEV Help Wanted
Discussion
Documentation
ESP32
Example
Good First Issue
Hotfix
In Progress
Incomplete
Needs Feeback
Priority
QA
Question
Task
Upstream/Dependancy
bug
duplicate
enhancement
invalid
pull-request
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/WiFiManager#1243
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jackkitley on GitHub (Jul 16, 2022).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1454
Basic Infos
Hardware
WiFimanager Branch/Release: Master
Esp8266/Esp32:
Hardware: D1 mini
Description
Im trying to reconnect to my known SSID that was successful but i cannot reconnect to it after a power outage. All the device does is boot up another AP which i dont want. I have tried multiple ways to keep restarting the device, wifi begin etc etc but i always starts a new AP on SSID not found boot up.
What i want to achieve:
After a power outage for the ESP device to keep retrying the known SSID from the config file.
I will handle a reset for AP manually if i wish to but all i want is on boot for the device to keep trying to connect to the known SSID as the routers take a while to boot.
Settings in IDE
Module: Wemos D1
Additional libraries:
Sketch
Debug Messages
@tablatronix commented on GitHub (Jul 16, 2022):
You will have to wait longer to reconnect since your ap is not up yet.. or add your own counter to retry.
wm does have a connectiontimeout and a retry count setting you can try increasing those.
esp is supposed to auto-reconnect in background, but it seems to be not working lately.
ideally you can just add your own check to keep reconnecting, and do not use autoconnect() or disable setEnableConfigPortal
@jackkitley commented on GitHub (Jul 16, 2022):
@tablatronix Thank you. Do you possibly have an example?
If i pull the power from wifi i can see serial trying to connect but if i pull power from device and then power up again it will go straight to AP and not try reconnect which is annoying. I want to avoid the AP at all costs.
@tablatronix commented on GitHub (Jul 16, 2022):
@jackkitley commented on GitHub (Jul 16, 2022):
The wifi could take in excess of 5min to come up again.
@jackkitley commented on GitHub (Jul 16, 2022):
@tablatronix ah, i have not seen setConnectRetries befone. I will make that max out haha
@tablatronix commented on GitHub (Jul 16, 2022):
depending on if you want your sketch to continue without wifi, you might want to goto sleep or add your own timer in loop to retry every minute or so if not connected.
I have to test out why the esp automatic reconnect has not been working, I have noticed this as well for the last several versions, i have yet to test it or see if wm is breaking it
@jackkitley commented on GitHub (Jul 16, 2022):
@tablatronix ive tried my own loop but doesnt seem to work. In South africa we have power out times. The whole house will be without electricity and when it comes back i want the ESP to just connect back again so i can get data into my home automation.
Its annoying if it sets up an AP.
@tablatronix commented on GitHub (Jul 16, 2022):
and to use autoconnect but not start cp ever ( ony on demand etc ) use
wm.setEnableConfigPortal(false)@jackkitley commented on GitHub (Jul 16, 2022):
@tablatronix i need WIFI for MQTT to publish my hot water times.
@jackkitley commented on GitHub (Jul 16, 2022):
Yes, its not great that it doesnt try last connected. It just boots into creating AP.
@jackkitley commented on GitHub (Jul 16, 2022):
@tablatronix
Look ok?
@tablatronix commented on GitHub (Jul 16, 2022):
If you have alot of power failures I would suggest you do not use configportal at all, and provide a manual reset or ondemand cp start.. Or add a counter like tasmota does, after x restarts start ap etc.
@jackkitley commented on GitHub (Jul 16, 2022):
@tablatronix
Yes, this is what i disabled for tasmota and what i wish to do for WM.
@jackkitley commented on GitHub (Jul 16, 2022):
i disabled for x retries, start AP because of power failures so it just connects to SSID when its back up
@jackkitley commented on GitHub (Jul 16, 2022):
@tablatronix How would you recommend i tackle this? im very new to this space of manual coding. i use Tasmota but develiped my own C++ for a custom device.
@jackkitley commented on GitHub (Jul 16, 2022):
@tablatronix
@jackkitley commented on GitHub (Jul 16, 2022):
@tablatronix i flashed device. First start up it spun up an AP.
@jackkitley commented on GitHub (Jul 16, 2022):
going to disconnect WIFI now.
@jackkitley commented on GitHub (Jul 16, 2022):
I powered up device but doesnt even try to connect to last SSID.
@jackkitley commented on GitHub (Jul 16, 2022):
Yes. Its not working at all on power failure.
@tablatronix commented on GitHub (Jul 16, 2022):
you still have to call autoconnect
you can also use bool getWiFiIsSaved(); if you want to allow for an initial setup
@jackkitley commented on GitHub (Jul 16, 2022):
hmm
I see getWiFiIsSaved in docs. Doesnt explain much. Ok, ill check on Wifi saved then and not force config. forceConfig is from my saved creds;
bool spiffsSetup = loadConfigFile();
if (!spiffsSetup)
{
Serial.println(F("Forcing config mode as there is no saved config"));
forceConfig = true;
}
setupWifiManager();
}
@jackkitley commented on GitHub (Jul 16, 2022):
if (!wifiManager.getWiFiIsSaved()) wifiManager.setEnableConfigPortal(false);
wifiManager.autoConnect("AP");
@jackkitley commented on GitHub (Jul 16, 2022):
@tablatronix on the right track! thanks bud
@SboleWork commented on GitHub (Aug 24, 2022):
@jackkitley were you able to get this sorted for your application?
My device seems to deal with loadshedding without problems.
When the power comes back on it tries to connect to the known network.
If it fails to connect to the known network - i.e. the router isn't up yet, it reverts to AP mode and allows me to connect to it and search for networks.
If I don't connect to it, it times out after 30 seconds, restarts the ESP32 and tries to connect to the known network.
This loops until either the router comes up and it connects or I connect to a new network.
@jackkitley commented on GitHub (Aug 24, 2022):
@SboleWork Hi. Got it sorted.
If it fails to connect to the known network - i.e. the router isn't up yet, it reverts to AP mode and allows me to connect to it and search for networks.- this was my problem. the router didnt boot fast enough and the tries were only a handful before it reverted to AP mode which i didnt want.Now it tries for a long time and eventually connects. I have a button which i use to revert back to AP mode.
I used the manager in my geyserwise project.
https://github.com/jackkitley/geyserwise_max_iot
@tablatronix commented on GitHub (Aug 24, 2022):
you just change the settings or add a wait loop in your code, the option is setconnecttimeout and numretries