Page 1 of 1

Fast wifi station connect?

Posted: Mon Feb 20, 2017 8:17 pm
by gatisp
I am considering using ESP32 for battery powered wifi sensor device so the power consumption is important.

As I have observed after the board boots up and esp_wifi_connect() is called it usually takes about 1.1 seconds till SYSTEM_EVENT_STA_CONNECTED happens. After that everything seems to work quick - DHCP acquires address in about 0.1 seconds and so on.

So it seems that wifi lib does a full scan of all the channels to look for appropriate/best accesspoint.

This makes me want to have some kind of "hinted" esp_wifi_connect() mode where it first scans just the channel it was last connected to the AP. And if the AP is still there (on same channel) proceed to connecting without scanning the other channels.

Such feature would allow to dramatically cut down "modem active" time and give big power saving in an application that requires just a few packet exchanges.

Is there such a feature planned?
What is esp_wifi_clear_fast_connect() about?

I was not able to find an SDK roadmap here.
Thanks in advance,

Re: Fast wifi station connect?

Posted: Wed Feb 22, 2017 10:00 pm
by gatisp
Ok, this is interesting.

Now I found that security takes a big part of connecting to AP.

I am running ESP32 at 240Mhz and best I got is 0.8 secs with WPA2 PSK till connected event on 2412 channel.

Without security I get connected to AP in 0.2 secs on 2412 channel.

Now the point about channel hint is still valid because when I set my AP to 2452 channel it takes ~1.4 seconds to connect without security. And ~2.0 seconds to connect with WPA2 PSK.

It is obvious that there is channel scanning overhead involved which I would like to avoid.

Not sure about the security overhead though. Because when security enabled connection time increases when I reduce cpu speed.
So at 80Mhz cpu speed it takes to 2.2secs to connect with security on 2412 channel.

Lets say 0.2sec per channel scan time.
0.8 - 0.2 = 0.6
2.2 - 0.2 = 2.0

2.0 / 0.6 roughly equals 240Mhz / 80Mhz.

Yeah. Probably since the modem takes more power than cpu (which is still on while doing security key calculation) it is better to run the cpu at 240Mhz.


In my application there is no way to avoid connecting to secured APs but I still would like to save more than 1 sec of modem on time while scanning to save power.

Please advise on how to improve wifi connection speed. Maybe there will be an option for a user provided scan-list? There already is the country setting, so it is kind of there already.

Thanks for info.

Re: Fast wifi station connect?

Posted: Thu Feb 23, 2017 9:20 am
by WiFive
Yes it would be nice to provide an ordered channel list when doing station connect and the option to either connect to first matching ssid or complete the scan and choose highest rssi.

Also coming up here in a different way https://esp32.com/viewtopic.php?f=13&t=1192