khoih-prog / ESPAsync_WiFiManager

This is an ESP32 (including ESP32-S2 and ESP32-C3) / ESP8266 WiFi Connection Manager, using ESPAsyncWebServer, with fallback web configuration portal. Use this library for configuring ESP32, ESP8266 modules' WiFi, etc. Credentials at runtime. You can also specify static DNS servers, personalized HostName, fixed or random AP WiFi channel. With examples supporting ArduinoJson 6.0.0+ as well as 5.13.5- . Using AsyncDNSServer instead of DNSServer now.
MIT License
291 stars 73 forks source link

DHCP Autoassign hangs and does not properly connect network. #10

Closed tpalaz closed 3 years ago

tpalaz commented 3 years ago

Hello. I have encountered an issue with this library with the DHCP not automatically assigning an IP/Gateway when the ESP82666 enters Station mode.

Here is a quick rundown of the logs I am receiving:

[WM] ESPAsync_WiFiManager::startConfigPortal : Enter loop
[WM] Connecting to new AP
[WM] Previous settings invalidated
[WM] Can't use Custom STA IP/GW/Subnet
[WM] Connect to new WiFi using new IP parameters
[WM] Connected after waiting (s) : 6.75
[WM] Local ip = (IP unset)
[WM] Connection result:  WL_NO_SSID_AVAIL
[WM] Failed to connect
Not connected to WiFi but continuing anyway.
[WM] * Add SSID =  SSIDNAMEHERE , PW =  networkPW
[WM] SaveWiFiCfgFile
[WM] OK
After waiting 0.00 secs more in setup(), connection result is WL_IDLE_STATUS
HTTP server started @ (IP unset)

After displaying this, it enters a loop without ever managing to gain a connection to the network.

WiFi lost. Call connectMultiWiFi in loop
[WM] ConnectMultiWiFi with :
[WM] * Additional SSID =  SSIDNAMEHERE, PW =  networkPW
[WM] Connecting MultiWifi...
[WM] WiFi not connected
F

Some notable configuration settings:

#define USER_DHCP_IP true

#if ( USE_DHCP_IP || ( defined(USE_STATIC_IP_CONFIG_IN_CP) && !USE_STATIC_IP_CONFIG_IN_CP ) )
  // Use DHCP
  #warning Using DHCP IP
  IPAddress stationIP   = IPAddress(0, 0, 0, 0);
  IPAddress gatewayIP   = IPAddress(192, 168, 1, 0);
  IPAddress netMask     = IPAddress(255, 255, 255, 0);

I have tried many times to re-upload the sketch, wipe the flash, etc. Oddly enough, I had it working at one point and made some modifications to sketch then reuploaded, and it stopped working.

Great library BTW! It's incredibly useful and feature filled.

khoih-prog commented 3 years ago

@tpalaz

Thanks for using the library and your encouraging words.

Are you sure

IPAddress gatewayIP   = IPAddress(192, 168, 1, 0);

is your GateWay IPAddress?

If correct, from the terminal output, it seems that

  1. Either you didn't input the correct SSID/PW into the Config Portal
  2. Or enter the wrong SSID/PW, DHCP info (gateway, subnet mask) into the Config Portal

Try to use the latest ESPAsync_WiFiManager v1.1.2 and the easiest to use Async_ConfigOnDoubleReset example so that you can enter/re-enter the Config Portal by DRD to check /verify the CP input.

I tried and retried, but still couldn't duplicate the problem. Hope you find out the reason.