ESP8266 and Wi-Fi Channels

By May 13, 2016ESP8266, IoT

The ESP8266 supports operating as a Wi-Fi station (station mode), an access point (softAP mode), and can even do both at the same time (softAP+station mode). However, there is one important detail that must be understood or else it will come back to bite you: the radio in the ESP8266 only supports one hardware channel at a time.

What does this mean? Well, 802.11b/g/n operating on 2.4GHz has 14 different channels that can be used (though, in North America, we can only use channels 1-11 due to regulations). The radio in the ESP8266 can only connect to one of those at a time.

This really only presents a problem when you run in softAP+station mode. Suppose that you start up the softAP on channel 6 and stations connect to it (i.e. maybe you’re using the End User Setup module of NodeMCU as a way to allow the user to set its station configuration). Then you configure the ESP’s Wi-Fi Station to connect to an access point on channel 1. What’s going to happen is that the station configuration will win, and the softAP will switch over to channel 1 also. This will drop the stations that had been previously connected to your softAP.

As mentioned above, the station mode configuration takes precedence. So, if the ESP’s Station is already connected to an access point on channel 1, then trying to start up the softAP on channel 6 will not work as planned (the softAP will start on channel 1, too). Usually, this is not a problem for your client stations, because they will do a channel scan to locate the softAP by SSID.

Finally, one of the trickier situations to troubleshoot is when the ESP8266 has a non-existent access point configured and is set to auto-reconnect (e.g., maybe it was previously connected to your work’s Wi-Fi network, and now the device is at your home). The ESP will continue to perform channel scans to locate that non-existent access point, resulting in the softAP channel changing, too. This usually presents itself as being difficult to connect to the softAP, or once connected, the client station may spontaneously disconnect, or communications may be slow or interrupted. The fix is to either clear out the station configuration to remove the non-existent access point, or to just disable the auto-reconnect for the station so that it does not keep trying.


The following two tabs change content below.
  • Navid

    I just curious about the name of the weblog. It is very deleterious!!


  • Craig Larson

    I think you are on to something in solving another one of my problems. I’m in a new LAN location and suffering 4 to 8 second delays on a client.connect attempt. I will attempt to figure out how to clear the station configuration via google. Any bread crumbs would be appreciated. Thanks, once again, for your work.

  • generalg

    Mad props! Just spent an entire night debugging code where I was switching from station mode to AP mode. Once in AP mode, any client I tired would only connect to the AP for a second then get dropped. Finally, I found this post. The code when the ESP was in station mode had a channel hopping function that I had been completely ignoring. All I had to do was disarm the timer for the channel hop before entering AP mode. Problem solved. Thank you!

  • atexit8

    What AT command do I use to remove the non-existent access point ?