Appearance
ESP32 Wi-Fi: joining the strongest access point on a mesh
Measured on a real ESP32 on 24 Oct 2026. Three access points, all on channel 2.
The board joined the weakest node (-79 to -84 dBm) instead of the nearest (-16 dBm). MQTT over WSS then failed with -0x7280 (MBEDTLS_ERR_SSL_CONN_EOF). Connecting took about 130 seconds.
With a full-channel scan sorted by signal, it joined the node at -15 to -17 dBm. Wi-Fi was up in 6.4 seconds. MQTT was up in 12.0 seconds. A shared attribute was received and applied 12.5 seconds after a hardware reset.
SDK option
AutoconnectoSDK 1.7.76 joins the strongest access point by default.
config.wifiJoinStrongest = truescans every channel and sorts by signal.falsekeeps the first match.config.wifiConnectTimeoutMsdefaults to 15 seconds.- A failed MQTT connect switches between WSS and MQTTS, then retries with a bounded backoff.
- Register
sdk.onWifiJoinbeforebegin. It receives BSSID, channel, and RSSI even whenenableSerialLogsis false.sdk.lastWifiJoinreads the same result. enableSerialLogs = falseprints no SDK log lines. The sketch can still print the join callback.- On boot the device takes the retained shared-attribute push. It does not send a second request when that push has already arrived.
examples/MqttConnectFault_mqtt fails the first two MQTT connects in software so the transport switch and the backoff can be checked without waiting for a dead broker.
Examples in the SDK:
examples/WifiJoinStrongest_mqttexamples/Attributes_RestoreOnBoot_mqtt— read shared attributes at boot, drive a GPIO, and report a client attribute.examples/MqttConnectFault_mqtt
