ESP32-Radio icon indicating copy to clipboard operation
ESP32-Radio copied to clipboard

ESP32 Won't Connect To My WiFi AP

Open prairietech opened this issue 1 year ago • 9 comments

The ESP32 won't connect to 3 different wifi APs I have tried but will connect to my cellphone when it's used as a wifi hotspot tether. Those wifi APs are all the same room as the ESP32. Otherwise, I get the WiFi Failed! error. My internet wifi AP ssid/password are entered under the FIXEDWIFI setting. Running the latest V2 download using Platformio.

When the connection fails, the ESP32 then goes into it's own AP mode which I can connect to using a laptop. I am able to submit changes from the web interface and they are accepted with the Serial Monitor confirming the action. From the web interface Config page, my Internet wifi AP is listed as available. I have also entered it under wifi_00 on the Config page, saved, then restarted only to have the connection still fail.

I can upload a simple wifi test sketch to the ESP32 and it will connect to the same Internet wifi AP entered under FIXEDWIFI. I have other ESP32s doing other tasks around the house and wifi connection has never been an issue.

I've tried everything I can think of, so looking for ideas and suggestions of what to try next?

prairietech avatar Mar 19 '23 14:03 prairietech

Maybe you can replace the wifi connect routine with a one that works on your other ESP32s. It's only a few lines.

Edzelf avatar Mar 19 '23 14:03 Edzelf

As you can tell, I'm a long ways from a programmer. Could you tell me where in the code those lines are?

prairietech avatar Mar 19 '23 14:03 prairietech

Search for "connect".

Edzelf avatar Mar 19 '23 14:03 Edzelf

1687 results in 88 files......may take awhile

prairietech avatar Mar 19 '23 15:03 prairietech

Start at line 3431.

Edzelf avatar Mar 19 '23 15:03 Edzelf

Below is starting from line 3431 of main.cpp Doesn't look like wifi commands?

static bool connected = false ; // Connected to host or not

if ( xQueueReceive ( radioqueue, &radiocmd, 0 ) ) // New command in queue? { dbgprint ( "Radiofuncs cmd is %d", radiocmd ) ; switch ( radiocmd ) // Yes, examine command { case QSTARTSONG: // Start a new station? if ( sdqueue )

prairietech avatar Mar 19 '23 17:03 prairietech

I had the wrong version. It is 1611: WiFi.disconnect ( true ) ; // After restart the router could WiFi.softAPdisconnect ( true ) ; // still keep the old connection vTaskDelay ( 1000 / portTICK_PERIOD_MS ) ; // Silly things to start connection WiFi.mode ( WIFI_STA ) ; vTaskDelay ( 1000 / portTICK_PERIOD_MS ) ; if ( wifilist.size() ) // Any AP defined? { if ( wifilist.size() == 1 ) // Just one AP defined in preferences? { winfo = wifilist[0] ; // Get this entry WiFi.begin ( winfo.ssid, winfo.passphrase ) ; // Connect to single SSID found in wifi_xx dbgprint ( "Try WiFi %s", winfo.ssid ) ; // Message to show

Edzelf avatar Mar 19 '23 18:03 Edzelf

I did not modify the wifi code but had a strange development. I noticed that the softAP of the ESP32 was operating from channel 1. So I locked my Internet wifi AP onto channel 1, hit the reset button on the ESP32 and got a connection!?!?

Anyone know why the ESP32 isn't scanning AP channels to find the correct SSID? This is the first time I have ever had to change the channel on an AP to match what the client is needing.

prairietech avatar Mar 19 '23 22:03 prairietech

Channel 1 to 11 should be acceptable. I am using 2 and 7 at home.

Edzelf avatar Mar 20 '23 08:03 Edzelf