Can't connect ESP32 to hostapd Access Point on Raspberry Pi (but it works with phone)

RichPiano
Posts: 42
Joined: Mon May 18, 2020 2:51 pm

Can't connect ESP32 to hostapd Access Point on Raspberry Pi (but it works with phone)

Postby RichPiano » Sat Jan 09, 2021 4:26 pm

I have the following problem:

I'm using the default wifi "station" example from esp-idf. Whenever I try to connect to my hostapd access point on my Raspberry Pi, it casts the following error message:

Code: Select all

..
I (4914) wifi station: retry to connect to the AP
I (4914) wifi station: connect to the AP fail
I (6954) wifi station: retry to connect to the AP
I (6954) wifi station: connect to the AP fail
I (9004) wifi station: retry to connect to the AP
I (9004) wifi station: connect to the AP fail
I (11054) wifi station: retry to connect to the AP
I (11054) wifi station: connect to the AP fail
And it will eventually say that a connection was not possible.

HOWEVER: The ESP32 connects flawlessly with my wifi-router!

And strangely enough, the access point seems to work as well, just not for the ESP32. I can connect to it with my phone and laptop just fine (I can even access internet through NAT).

This is my hostapd.conf

Code: Select all

river=nl80211
ssid=someSSID
country_code=CH
hw_mode=g
channel=6
auth_algs=1
wpa=2
wpa_passphrase=somePWD
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
logger_syslog=-1
logger_syslog_level=0
logger_stdout=-1
logger_stdout_level=0
(I have enabled verbose logging to syslog and stdout in the hopes that it will log incoming failed connections, but it doesn't)

What am I doing wrong?

RichPiano
Posts: 42
Joined: Mon May 18, 2020 2:51 pm

Re: Can't connect ESP32 to hostapd Access Point on Raspberry Pi (but it works with phone)

Postby RichPiano » Sun Jan 17, 2021 9:03 pm

The problem was that the raspi was adapting to the local network, which was using the 5 GHz band at the time. hostapd will use the same channel for the AP as wpa_supplicant does, even if the configuration in hostapd.conf says different.

I solved the problem by tuning the raspi into a 2.4 GHz network. I'm also experimenting with setting the scan frequencies in wpa_supplicant itself, so it only connects to the 2.4 Ghz band, but I'm not done testing yet.

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], tschak909 and 31 guests