Edzelf / ESP32-Radio

Internet radio based on ESP32, VS1053 and a TFT screen.
GNU General Public License v3.0
964 stars 227 forks source link

ESP32 Won't Connect To My WiFi AP #517

Open prairietech opened 1 year ago

prairietech commented 1 year ago

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?

Edzelf commented 1 year ago

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

prairietech commented 1 year ago

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

Edzelf commented 1 year ago

Search for "connect".

prairietech commented 1 year ago

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

Edzelf commented 1 year ago

Start at line 3431.

prairietech commented 1 year ago

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 )

Edzelf commented 1 year ago

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

prairietech commented 1 year ago

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.

Edzelf commented 1 year ago

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