1

It has already been asked how many clients can connect to an ESP32 AP, but the answer is far from clear; the best one is from a year and half ago (ESP32 AP max connections: 4 or 10?) :

The answer is as clear as any other EspressIf configuration data, it is 4 or maybe 5, or 8, or 12, 16 or even 20 (the same as a ESP8266!)

As I'm trying to move a project from the ESP8266 because it does not have enough AP connections, two questions can be asked :

  1. what is the maximum number of AP connections supported by the 4.0 ESP-IDF framework ?

  2. can it be increased in any way ?

Thank you.

stefanu
  • 131
  • 4

2 Answers2

2

After some extensive testing with several modules (not just blindly trusting the documentation), here's what I found.

Short answer : maximum 10 AP connections for the ESP32 running ESP-IDF 4.0 (updated around 1st of march 2020), and no, it can't be increased (easily).

Details :

  • The maximum number of AP connections is defined somewhere in libnet80211, and can't be modified since I have no access to the source code.
  • when the 11th station tries to connect, libnet80211 prints I (39682043) wifi: max connection, deauth!, more or less like the ESP8266 for the 5th station
  • Changine the ESP_WIFI_MAX_CONN_NUM (defined in esp_wifi_types.h:258) from 10 to anything else ends up in unpredictable behavior (I'm labelling this as unpredictable since without the libnet80211 code, it can't be reliably assessed).

I'm not giving up on increasing the number of stations yet, so maybe there'll be an update to this answer.

stefanu
  • 131
  • 4
0

According to the documentation:

uint8_t max_connection

Max number of stations allowed to connect in, default 4, max 4

The WiFi interface and AP can support up to 10 connections in its internal structures, but that is only practical for WiFi Mesh usage (which doesn't use all 7 layers of the ISO model), and for actual WiFi station connections, which entails the allocation of far more resources (IP addresses, ARP tables, etc) only a maximum of 4 are supported.

If you need more connections I suggest you invest in a real access point / router which can deal with the network management for you (i.e., an access point or router which can do the DHCP and other networking housekeeping for you, leaving your ESP32 free to be a simple station).

Majenko
  • 105,095
  • 5
  • 79
  • 137
  • this is copy-paste from esp8266 doc – Juraj Feb 28 '20 at 17:07
  • No, it's a quote from the ESP32 documentation. Hence the link to the ESP32 documentation. – Majenko Feb 28 '20 at 17:22
  • Yes, it’s a quote from the documentation, but how reliable is the documentation ? – stefanu Feb 29 '20 at 09:59
  • If you search in the ESP-IDF files you will find ESP_WIFI_MAX_CONN_NUM=10, – stefanu Feb 29 '20 at 10:05
  • It looks like in 2016 they changed from a linked list to a static array for storage of connected stations. Since then the size of that static array has changed. For some reason the define started as 8, but the array was created as 8+2. Then the define changed to 10 and the array was also created directly from that define instead of adding 2. No idea what the significance of the "+2" was. However, the 10 is not for wifi. The 10 is for mesh. How many connections it supports, and how many are allowed are different things. The WiFi itself can support 10, which is fine for mesh use, but ... – Majenko Feb 29 '20 at 11:16
  • ... for actual processing of connections it's limited to just 4 connections, since active connections to the IP stack use more resources. – Majenko Feb 29 '20 at 11:16
  • Thank you for the explanation. But the second question still stands ... can it be altered in any way ? – stefanu Mar 02 '20 at 06:37
  • @stefanu Probably not. If the IDF limits it then there's not a lot you can do. You could try manually configuring the AP mode (incidentally I notice in the ESP-IDF code for doing that it's actually setting the number of connections to 5...) or adjust start_wifi_ap and see if that works. It may not though, since you may run out of memory – Majenko Mar 02 '20 at 10:12
  • Thank you for the info; I'm in the process of replacing the ESP8266 with the ESP32 and I will soon be able to test the AP limits (as soon as I receive more chips to test with).

    I will get back with the results.

    What I've been able to test so far is that changing the

    #define ESP_WIFI_MAX_CONN_NUM 10

    to

    #define ESP_WIFI_MAX_CONN_NUM 16 then rebuilding everything, does change the sizeof(wifi_sta_list_t), so ... maybe... just maybe ... there's a chance.

    – stefanu Mar 02 '20 at 19:37
  • @Majenko : well...the documentation is WRONG ! Without any hacking at lower levels I was able to connect 8 stations in APSTA mode. On the other hand, changing the ESP_WIFI_MAX_CONN_NUM to a greater value produces strange behavior (for instance esp_wifi_ap_get_sta_list fails miserably). I will get back once I have more modules to play with. – stefanu Mar 07 '20 at 04:22