[GH-ISSUE #227] Auto connect / Hotspot Can't connect to ESP8266 to setup the wifi configuration #188

Closed
opened 2026-02-28 01:23:55 +03:00 by kerem · 11 comments
Owner

Originally created by @ejbp on GitHub (Sep 13, 2016).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/227

When the esp8266 doesn't find a wifi to connect, auto connect provides a hotspot but i need to try (sometimes more than 5 minutes after plug/unplug the chip many times) to connect to the hotspot. It seems the problem is that, for some reason, it doesn't provide an ip address to the client. If I try with a static ip in the client side, it works, but this is not production friendly.

Here's the code:
WiFiManager wifiManager; wifiManager.setDebugOutput(true); wifiManager.setSaveConfigCallback(saveConfigCallback); wifiManager.setAPCallback(configModeCallback); wifiManager.setAPStaticIPConfig(IPAddress(10,0,1,1), IPAddress(10,0,1,1), IPAddress(255,255,255,0)); wifiManager.setTimeout(360); if(!wifiManager.autoConnect("Wifi-box")) { delay(3000); ESP.reset(); delay(5000); }

Attached are the libraries versions that I'm using:

screen shot 2016-09-13 at 09 46 34 screen shot 2016-09-13 at 09 47 01 screen shot 2016-09-13 at 09 47 11 screen shot 2016-09-13 at 09 47 35
Originally created by @ejbp on GitHub (Sep 13, 2016). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/227 When the esp8266 doesn't find a wifi to connect, auto connect provides a hotspot but i need to try (sometimes more than 5 minutes after plug/unplug the chip many times) to connect to the hotspot. It seems the problem is that, for some reason, it doesn't provide an ip address to the client. If I try with a static ip in the client side, it works, but this is not production friendly. Here's the code: ` WiFiManager wifiManager; wifiManager.setDebugOutput(true); wifiManager.setSaveConfigCallback(saveConfigCallback); wifiManager.setAPCallback(configModeCallback); wifiManager.setAPStaticIPConfig(IPAddress(10,0,1,1), IPAddress(10,0,1,1), IPAddress(255,255,255,0)); wifiManager.setTimeout(360); if(!wifiManager.autoConnect("Wifi-box")) { delay(3000); ESP.reset(); delay(5000); } ` Attached are the libraries versions that I'm using: <img width="758" alt="screen shot 2016-09-13 at 09 46 34" src="https://cloud.githubusercontent.com/assets/2060105/18467270/3795cd76-7997-11e6-91af-71c99d3574e2.png"> <img width="767" alt="screen shot 2016-09-13 at 09 47 01" src="https://cloud.githubusercontent.com/assets/2060105/18467272/379e48ca-7997-11e6-9f01-aea6640b4a46.png"> <img width="766" alt="screen shot 2016-09-13 at 09 47 11" src="https://cloud.githubusercontent.com/assets/2060105/18467269/37920966-7997-11e6-8cb2-e7cebcd3e9b2.png"> <img width="762" alt="screen shot 2016-09-13 at 09 47 35" src="https://cloud.githubusercontent.com/assets/2060105/18467271/379872d8-7997-11e6-9f86-44ee605011ca.png">
kerem closed this issue 2026-02-28 01:23:55 +03:00
Author
Owner

@tzapu commented on GitHub (Sep 13, 2016):

hi

could you try on another module as well? my connection is usually instant, from an ios device...

also, make sure you set the right flash size for your esp module

cheers

<!-- gh-comment-id:246617421 --> @tzapu commented on GitHub (Sep 13, 2016): hi could you try on another module as well? my connection is usually instant, from an ios device... also, make sure you set the right flash size for your esp module cheers
Author
Owner

@ejbp commented on GitHub (Sep 14, 2016):

Hi, You mean using another module other than WifiManager? Meanwhile, I'll do some debug.

An important detail could be the number of networks that are around. Everytime I have problems I notice that there's is a lot of wifi networks around. I'll try to do it in a "quiet" place (without many wifi networks).

As a note: It happens with any device, android, iPhone, laptop, tablet...

<!-- gh-comment-id:246915143 --> @ejbp commented on GitHub (Sep 14, 2016): Hi, You mean using another module other than WifiManager? Meanwhile, I'll do some debug. An important detail could be the number of networks that are around. Everytime I have problems I notice that there's is a lot of wifi networks around. I'll try to do it in a "quiet" place (without many wifi networks). As a note: It happens with any device, android, iPhone, laptop, tablet...
Author
Owner

@tzapu commented on GitHub (Sep 14, 2016):

hi

i meant another esp8266 module

cheers
alex

On 14 Sep 2016, at 09:06, While True notifications@github.com wrote:

Hi, You mean using another module other than WifiManager? Meanwhile, I'll do some debug.
As a note: It happens with any device, android, iPhone, laptop, tablet...


You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/tzapu/WiFiManager/issues/227#issuecomment-246915143, or mute the thread https://github.com/notifications/unsubscribe-auth/AC2FkLiVJQA7Kattk0dvzbI3rDhedkrfks5qp47PgaJpZM4J7bY-.

<!-- gh-comment-id:246931637 --> @tzapu commented on GitHub (Sep 14, 2016): hi i meant another esp8266 module cheers alex > On 14 Sep 2016, at 09:06, While True notifications@github.com wrote: > > Hi, You mean using another module other than WifiManager? Meanwhile, I'll do some debug. > As a note: It happens with any device, android, iPhone, laptop, tablet... > > — > You are receiving this because you commented. > Reply to this email directly, view it on GitHub https://github.com/tzapu/WiFiManager/issues/227#issuecomment-246915143, or mute the thread https://github.com/notifications/unsubscribe-auth/AC2FkLiVJQA7Kattk0dvzbI3rDhedkrfks5qp47PgaJpZM4J7bY-.
Author
Owner

@ejbp commented on GitHub (Sep 15, 2016):

Hi

After some debug I think I discovered what is causing the problem.

If you setup/connect to an wifi network with success through your esp8266 that configuration is saved, as expected. Next time you turn on the esp8266, it connects to that same wifi, if available, as expected too.

The problem starts when esp8266 doesn't find that wifi available anymore, so it starts in the process of trying to reconnect, scan all networks, trying to reconnect (in 1s in 1s) and at same time, trying to reply to serve as hotspot with all the dhcp, dns, http(captive) services trying to run and reply. If you have a few wifi networks around this is not a problem, but if you have to many, the esp probably doesn't have time enough to process all of those services in time and therefore, doesn't allow you to connect to it, or if it does (with luck) you will have the same problems trying to have the http captive server answering to you.

I'll try to figure out how to change the 1s to 5s or even 10s and comeback to double confirm that that was the problem.

update*
For what I've read in this forum http://bbs.espressif.com/viewtopic.php?t=671 there's no way to change the interval. In this link you also can understand deeply what is the problem. Going for the workaround, now.

<!-- gh-comment-id:247241799 --> @ejbp commented on GitHub (Sep 15, 2016): Hi After some debug I think I discovered what is causing the problem. If you setup/connect to an wifi network with success through your esp8266 that configuration is saved, as expected. Next time you turn on the esp8266, it connects to that same wifi, if available, as expected too. The problem starts when esp8266 doesn't find that wifi available anymore, so it starts in the process of trying to reconnect, scan all networks, trying to reconnect (in 1s in 1s) and at same time, trying to reply to serve as hotspot with all the dhcp, dns, http(captive) services trying to run and reply. If you have a few wifi networks around this is not a problem, but if you have to many, the esp probably doesn't have time enough to process all of those services in time and therefore, doesn't allow you to connect to it, or if it does (with luck) you will have the same problems trying to have the http captive server answering to you. I'll try to figure out how to change the 1s to 5s or even 10s and comeback to double confirm that that was the problem. **update*** For what I've read in this forum [http://bbs.espressif.com/viewtopic.php?t=671](http://bbs.espressif.com/viewtopic.php?t=671) there's no way to change the interval. In this link you also can understand deeply what is the problem. Going for the workaround, now.
Author
Owner

@tzapu commented on GitHub (Sep 19, 2016):

if you think this is the issue, you can add a WiFi.disconnect() before starting the configuration portal to test.

that should stop it trying to connect while in setup mode.

cheers

<!-- gh-comment-id:247945504 --> @tzapu commented on GitHub (Sep 19, 2016): if you think this is the issue, you can add a WiFi.disconnect() before starting the configuration portal to test. that should stop it trying to connect while in setup mode. cheers
Author
Owner

@kentaylor commented on GitHub (Sep 25, 2016):

I doubt the scenario suggested in https://github.com/tzapu/WiFiManager/issues/227#issuecomment-247241799 is occurring because the ESP8266 is put into access point (AP) mode when the portal is set up (see https://github.com/tzapu/WiFiManager/blob/master/WiFiManager.cpp#L154) . In AP mode it doesn't try to connect to another WiFi network so it is not "in the process of trying to reconnect".

Corection: It is put into dual mode so it is "in the process of trying to reconnect" and the scenario is likely.

In dual mode however it does try to connect to an access point and the WiFi Manager version at https://github.com/kentaylor/WiFiManager/ does use dual mode sometimes. This tells me the explanation of why it has to switch out of dual mode at https://github.com/kentaylor/WiFiManager/blob/master/WiFiManager.cpp#L204 is wrong and needs to be updated with this explanation.

<!-- gh-comment-id:249402098 --> @kentaylor commented on GitHub (Sep 25, 2016): I doubt the scenario suggested in https://github.com/tzapu/WiFiManager/issues/227#issuecomment-247241799 is occurring because the ESP8266 is put into access point (AP) mode when the portal is set up (see https://github.com/tzapu/WiFiManager/blob/master/WiFiManager.cpp#L154) . In AP mode it doesn't try to connect to another WiFi network so it is not "in the process of trying to reconnect". **Corection: It is put into dual mode so it is "in the process of trying to reconnect" and the scenario is likely.** In dual mode however it does try to connect to an access point and the WiFi Manager version at https://github.com/kentaylor/WiFiManager/ does use dual mode sometimes. This tells me the explanation of why it has to switch out of dual mode at https://github.com/kentaylor/WiFiManager/blob/master/WiFiManager.cpp#L204 is wrong and needs to be updated with this explanation.
Author
Owner

@klemic commented on GitHub (Sep 25, 2016):

Hi,
when using the ESP8266 version 2.3.0 (and ver 2.2.0 too)I have the same issue, the ESP is not connecting to the Wifi, when downgrading to version 2.1.0 it works always...

<!-- gh-comment-id:249441206 --> @klemic commented on GitHub (Sep 25, 2016): Hi, when using the ESP8266 version 2.3.0 (and ver 2.2.0 too)I have the same issue, the ESP is not connecting to the Wifi, when downgrading to version 2.1.0 it works always...
Author
Owner

@kentaylor commented on GitHub (Sep 25, 2016):

@klemic there are lots of things fixed in later ESP8266 library versions so I wouldn't be downgrading to get better functionality from WiFiManager.

Change this line https://github.com/tzapu/WiFiManager/blob/master/WiFiManager.cpp#L154 to WiFi.mode(WIFI_AP); and it will no longer be trying to connect to another network when in configuration mode. That will fix it if the scenario in https://github.com/tzapu/WiFiManager/issues/227#issuecomment-247241799 outlined by @ejbp is correct.

You could try the version at https://github.com/kentaylor/WiFiManager/ which doesn't use dual mode when the configured WiFi network is not available.

You can also see what has changed between ESP8266 library versions and investigate why older versions work better in this case but that requires more effort than I think it is worth.

<!-- gh-comment-id:249455021 --> @kentaylor commented on GitHub (Sep 25, 2016): @klemic there are lots of things fixed in later ESP8266 library versions so I wouldn't be downgrading to get better functionality from WiFiManager. Change this line https://github.com/tzapu/WiFiManager/blob/master/WiFiManager.cpp#L154 to WiFi.mode(WIFI_AP); and it will no longer be trying to connect to another network when in configuration mode. That will fix it if the scenario in https://github.com/tzapu/WiFiManager/issues/227#issuecomment-247241799 outlined by @ejbp is correct. You could try the version at https://github.com/kentaylor/WiFiManager/ which doesn't use dual mode when the configured WiFi network is not available. You can also see what has changed between ESP8266 library versions and investigate why older versions work better in this case but that requires more effort than I think it is worth.
Author
Owner

@klemic commented on GitHub (Sep 26, 2016):

Hi Ken, thanks a lot. However, the problem is not the configuration mode. When using the old library the ESP is just connecting to the last known Wifi and not entering the configuration mode at all. When using the new library the ESP is almost never connecting to the exisiting WIfi and then entering the configuration mode. So there is already something wrong before.

You're right, the effort to find the reason is a problem, that's why I helped me with downgrading...

<!-- gh-comment-id:249479457 --> @klemic commented on GitHub (Sep 26, 2016): Hi Ken, thanks a lot. However, the problem is not the configuration mode. When using the old library the ESP is just connecting to the last known Wifi and not entering the configuration mode at all. When using the new library the ESP is almost never connecting to the exisiting WIfi and then entering the configuration mode. So there is already something wrong before. You're right, the effort to find the reason is a problem, that's why I helped me with downgrading...
Author
Owner

@kentaylor commented on GitHub (Sep 26, 2016):

@klemic it sounds like your issue is different to the issue described by @ejbp.

The WiFi Manager version at https://github.com/kentaylor/WiFiManager/ doesn't use dual mode when the configured WiFi network is not available so should be a solution to the issue described by @ejbp .

Also the fix provided by @lawrence-jeff and discussed at https://github.com/tzapu/WiFiManager/issues/215#issuecomment-249485865 should work also.

<!-- gh-comment-id:249487913 --> @kentaylor commented on GitHub (Sep 26, 2016): @klemic it sounds like your issue is different to the issue described by @ejbp. The WiFi Manager version at https://github.com/kentaylor/WiFiManager/ doesn't use dual mode when the configured WiFi network is not available so should be a solution to the issue described by @ejbp . Also the fix provided by @lawrence-jeff and discussed at https://github.com/tzapu/WiFiManager/issues/215#issuecomment-249485865 should work also.
Author
Owner

@klemic commented on GitHub (Sep 26, 2016):

@kentaylor yes, it seems so...

<!-- gh-comment-id:249564431 --> @klemic commented on GitHub (Sep 26, 2016): @kentaylor yes, it seems so...
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#188
No description provided.