tzapu / WiFiManager

ESP8266 WiFi Connection manager with web captive portal
http://tzapu.com/esp8266-wifi-connection-manager-library-arduino-ide/
MIT License
6.47k stars 1.95k forks source link

Wifi portal AP unreachable #758

Open nedimhx opened 5 years ago

nedimhx commented 5 years ago

Hello,

I have notice sometimes on some esp8266 devices, that I'm not unable to connect to Protal AP so I can configure wifi settings for esp to connect to router. But using that same esp on another location, I don't have problem.

When I'm unable to conncet to AP, after trying to connect, AP juste went away and again showed, secon case is, I have sucessfull connection to AP, but captive portal is not shown or if its shown, when I click scan networks it's just getin slow, and finnaly unable to connect to wifi network.

I have try completle to erase flas and upload code again from arduino ide but still the sam problem.

And after using that esp in other place like workshop its ok and captive portal working fine.

Can it be due to much wifi radio signals working on channel 1 and how is possible to set another radio signap channel in wifimanager.cpp

Regards

tablatronix commented 5 years ago

try development

nedimhx commented 5 years ago

My latest version was be 0.11 and im updated to 0.14

Hope so this will fix issue.

nedimhx commented 5 years ago

@tablatronix in the meantime how is possible to change Portal AP channal from 1 to some more rare radio signal channel ?

tablatronix commented 5 years ago

What meantime, try the development branch to see if it has been fixed already.

You can also try the hotfixes branch which disabled sta mode to stabilize the softap

tablatronix commented 5 years ago

You will have to manually change the code to start ap with channel, is your esp connected to a router?

fzoccara commented 5 years ago

Hello everybody, I had the same problem, connecting to device wifi was not possibile, I'd experience this only in wifi crowd places. Then I've fix my connection problem by changing the default wifi channel (1) to a custom one (6), directly in the library :( .

In file Arduino\libraries\WiFiManager\WiFiManager.cpp by replace following rows:

  if (_apPassword != NULL) {
    WiFi.softAP(_apName, _apPassword);//password option
  } else {
    WiFi.softAP(_apName);
  }

with these rows:

  if (_apPassword != NULL) {
    WiFi.softAP(_apName, _apPassword, 6);//password option
  } else {
    WiFi.softAP(_apName, NULL, 6);
  }

Is it possibile in a future version to make wifi channel configurable? UPDATE: I've seen in the future release there will be the channel configuration feature!! Super!!

Best. Francesco.

nedimhx commented 5 years ago

@fzoccara After adding channel number as you told I got this error while compileing

Arduino: 1.8.4 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, 4M (1M SPIFFS), v2 Lower Memory, Disabled, None, All Flash Contents, 115200"

C:\Users\nedim\Documents\Arduino\libraries\WiFiManager\WiFiManager.cpp: In member function 'void WiFiManager::setupConfigPortal()':

C:\Users\nedim\Documents\Arduino\libraries\WiFiManager\WiFiManager.cpp:134:27: error: invalid conversion from 'int' to 'const char*' [-fpermissive]

 WiFi.softAP(_apName, 3);

                       ^

In file included from C:\Users\nedim\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.1\libraries\ESP8266WiFi\src/ESP8266WiFi.h:35:0,

             from C:\Users\nedim\Documents\Arduino\libraries\WiFiManager\WiFiManager.h:16,

             from C:\Users\nedim\Documents\Arduino\libraries\WiFiManager\WiFiManager.cpp:13:

C:\Users\nedim\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.1\libraries\ESP8266WiFi\src/ESP8266WiFiAP.h:39:14: error: initializing argument 2 of 'bool ESP8266WiFiAPClass::softAP(const char, const char, int, int, int)' [-fpermissive]

     bool softAP(const char* ssid, const char* passphrase = NULL, int channel = 1, int ssid_hidden = 0, int max_connection = 4);

          ^

exit status 1 Error compiling for board NodeMCU 1.0 (ESP-12E Module).

This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.

fzoccara commented 5 years ago

Hi @nedimhx , you'd better check your row code: WiFi.softAP(_apName, 3);

instead of WiFi.softAP(_apName, NULL, 3);

the error is eloquent:

C:\Users\nedim\Documents\Arduino\libraries\WiFiManager\WiFiManager.cpp:134:27: error: invalid conversion from 'int' to 'const char*' [-fpermissive]

You are passing the channel id to the function softAP, where the function softAP expecting the password.

Best. Francesco.

nedimhx commented 5 years ago

@fzoccara thank you I forgot on that, thank you very much !

tablatronix commented 5 years ago

I was testing a similar method in development branch, but I did not add any public methods to set channel, instead I added _channelSync which will set the ap to the same channel as sta to increase reliability.

I was thinking about another way to auto change channel if there was any way to detect failures, but I have not tested any of this, I still think the problem is not the channel, As I have not observed that much congestion with my wifi scanner, It is possible this is anecdotal and fixing some other problem,

also note that simply stopping sta mode when using softap already fixes alot of issues, especially when sta has bad or no connection ( there is a background wifi scan that constantly changes channels ) This is already applied in hotfixes branch

It would be interesting to get feedback on both of these to see if it fixes the problem

fzoccara commented 5 years ago

Hi @tablatronix , At first I was thinking exactly like how you are thinking. However the same firmware on the same device was not working at the office only during crowd times, at home or in empty same office everything was regular.

Could be STA mode be itself part of the channel crowding? No further clue about any other cause, sorry. :)

Best. Francesco.

tablatronix commented 5 years ago

No but I seem to find it varies with devices as well, I have to be right next to my esp at work where I have 30+ aps, with my laptop, but my phone has no problem connecting. So I am not really sure what the deal is, I also noticed that the esp defaults to identifying itself as CN which sets invalid frequencies and could also cause problems with devices refusing to connect to it.

I added setCountry to development to try to help with that also with limited success.

So more testing for development branch and these 2 options would help us figure out a good way to fix these issues , and if crowding is indeed the problem, or if the esp is not rf calibrating properly on boot, or if the sdk has a bug or a limitation, I do know that soft+sta is problematic and it says so in the sdk

Increasing reliability is my goal, wether it be rotating channels ( esp is supposed to do this for us ) or disabling modem sleep ( that is another one I have not tested )

so far solutions to test are

WiFi.mode(WIFI_AP);
WiFi.setSleepMode(WIFI_NONE_SLEEP); // disable sleep, can improve ap stability
wm.setCountry("US"); // esp_wifi_set_country({"US",1,11,WIFI_COUNTRY_POLICY_AUTO})

There are separate issues with the captive portal, so testing with it disabled is preferred.

nedimhx commented 5 years ago

@tablatronix This issue is definetly becouse of crowd places, I have test it again just for you, I use my bare esp 12e module wich purpose is to be RFID reader, but problem with AP was be all time, now I have reuploaded same code wich was be upload earlier, only modified wifi manager and set it on channel 3 instead of default 1, and module is working 100% fine, I have a couple of them wich I will test all.

By the way, can you guys sugest me wich is the best electric circute to solder for the best esp 12e stability and reliability ?

paytah232 commented 4 years ago

When using wifiManager.autoConnect(ssid, pass), how can I try channel 3 instead of channel 1?

tablatronix commented 4 years ago

all examples are in the DEV/ example

  // set channel
  // wm.setWiFiAPChannel(13);