mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-27 00:55:52 +03:00
[GH-ISSUE #840] What if cannot connect to router? #705
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#705
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 @panosss on GitHub (Mar 4, 2019).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/840
Hi everybody.
I was studying the code in the AutoConnectWithTimeOut example.
#include //https://github.com/esp8266/Arduino //needed for library #include #include #include //https://github.com/tzapu/WiFiManager void setup() { // put your setup code here, to run once: Serial.begin(115200); //WiFiManager //Local intialization. Once its business is done, there is no need to keep it around WiFiManager wifiManager; //reset settings - for testing //wifiManager.resetSettings(); //sets timeout until configuration portal gets turned off //useful to make it all retry or go to sleep //in seconds wifiManager.setTimeout(180); //fetches ssid and pass and tries to connect //if it does not connect it starts an access point with the specified name //here "AutoConnectAP" //and goes into a blocking loop awaiting configuration if(!wifiManager.autoConnect("AutoConnectAP")) { Serial.println("failed to connect and hit timeout"); delay(3000); //reset and try again, or maybe put it to deep sleep ESP.reset(); delay(5000); } //if you get here you have connected to the WiFi Serial.println("connected...yeey :)"); } void loop() { // put your main code here, to run repeatedly: }Let's say that my router has no power.
So my ESP82266 cannot connect to internet and the code gets stuck forever at:
Right?
So how can I make it go to the code in the main loop in this case?
What I want is this:
-at setup, try to connect to wifi
-if succeeds ok no problem If fails, again no problem, BUT don't get stucked here, continue to main loop and.
-while at main loop, try at sometime to reconnect to wifi
@tablatronix commented on GitHub (Mar 4, 2019):
setConfigPortalTimeout
@panosss commented on GitHub (Mar 5, 2019):
I suppose you mean this?
From what I see, the user has to press a button for the ESP to try to connect to the WiFi, right?
This means that it cannot be done automatically but only by the intervention of the user?
@tablatronix commented on GitHub (Mar 5, 2019):
No , its in the docs.
https://github.com/tzapu/WiFiManager#configuration-portal-timeout
You do not have to deal with reconnect, esp does it automatically, just check for connected now and then , or startConfigPortal on demand
@panosss commented on GitHub (Mar 5, 2019):
How about this code? It tries to connect for 3 minutes, and if doesn't succeed just proceeds to main loop????
#include //https://github.com/esp8266/Arduino //needed for library #include #include #include //https://github.com/tzapu/WiFiManager void setup() { // put your setup code here, to run once: Serial.begin(115200); WiFiManager wifiManager; wifiManager.setConfigPortalTimeout(180); if(!wifiManager.autoConnect("AutoConnectAP")) { Serial.println("failed to connect and hit timeout"); delay(3000); //reset and try again, or maybe put it to deep sleep ESP.reset(); delay(5000); } //if you get here you have connected to the WiFi Serial.println("connected...yeey :)"); } void loop() { // put your main code here, to run repeatedly: }@tablatronix commented on GitHub (Mar 5, 2019):
That will start the configportal and timeout after 180 seconds
if you want to try to connect for 3 minutes use setConnectTimeout
autoconnect->connecttwifitimer->configportalloop( no reconnection occurs here, atm )
@panosss commented on GitHub (Mar 5, 2019):
No, I don't want to try to connect for 3 minutes.
I just descried what I thought it does. I was wrong.
So, my program now is completely ok?
If it does not connect at setup, it will, automatically, try to connect sometime at the main loop?
@tablatronix commented on GitHub (Mar 5, 2019):
well no because you have
ESP.reset();
@dontsovcmc commented on GitHub (Mar 27, 2019):
@tablatronix my way is right or I can use setConnectTimeout?
@tablatronix commented on GitHub (Mar 27, 2019):
Both should work