How to fix ESP32 WiFi “connection failed” or weak signal problems
WiFi failures look like “code problems,” but a lot of the time it's just physics: distance, walls, interference, and a tiny antenna on a dev board.
Check signal strength (RSSI)
RSSI is reported in dBm. Closer to 0 is stronger. Rough guide:
- -40 to -60 dBm: solid
- -60 to -70 dBm: usually OK
- -70 to -80 dBm: flaky
- worse than -80 dBm: expect dropouts
#include <WiFi.h>
const char* ssid = "YOUR_WIFI_NAME";
const char* password = "YOUR_WIFI_PASSWORD";
void setup() {
Serial.begin(115200);
delay(200);
WiFi.mode(WIFI_STA);
WiFi.setSleep(false);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println();
Serial.println("Connected.");
}
void loop() {
Serial.print("RSSI: ");
Serial.print(WiFi.RSSI());
Serial.println(" dBm");
delay(2000);
}Fixes that actually move the needle
- Move the ESP32. A 30cm move can be the difference between -78 and -62 dBm.
- Keep it away from metal and wiring bundles. Enclosures and big ground planes can detune the antenna.
- Try a different channel. 2.4GHz is crowded; channel 1/6/11 are the usual options.
- Use a better access point location or add a mesh node closer.
Common “router settings” gotchas
- Band steering can confuse some clients. If your router has separate 2.4/5 SSIDs, use the 2.4 SSID.
- WPA3-only can cause failures. Try WPA2/WPA3 mixed.
- Guest networks sometimes block IoT-style traffic.
Bottom line
If RSSI is worse than about -70 dBm, fix the signal first: placement, channel, and access point location. Once the link is stable, the code usually “magically” works.
Related: Connect ESP32 to WiFi · Disconnects / stays disconnected · ESP32 WiFi scan