ESP32 Not Connecting to Wi-Fi? Here’s How to Fix It

Your ESP32 sketch compiles fine, you hit upload — but the board just won’t connect to Wi-Fi? You’re not alone. Wi-Fi connection issues are one of the most common problems ESP32 beginners (and experienced makers) run into. This guide walks you through the most frequent causes and how to fix them.

Quick Overview: Common Causes at a Glance

CauseQuick Fix
Wrong SSID or passwordDouble-check credentials, check for spaces
5 GHz networkSwitch to 2.4 GHz
Signal too weakMove the ESP32 closer to the router
IP conflict / DHCP issueUse a static IP or restart the router
Wrong Wi-Fi mode in codeAdd WiFi.mode(WIFI_STA)
Power supply issueUse USB power, not the 3.3V pin directly
Corrupted firmwareAdd a Timeout and Reconnect Logic

Fix 1: Wrong SSID or Password

This is the most common culprit — and the easiest to overlook. Wi-Fi credentials in Arduino code are case-sensitive, and even a single wrong character will prevent the connection.

  • Make sure SSID and password match exactly — including uppercase letters
  • Watch out for leading or trailing spaces in your string literals
  • If your SSID contains special characters, try renaming your network temporarily to something simple
  • Test with a mobile hotspot to rule out router-specific issues
const char* ssid = "YourNetworkName";   // case-sensitive!
const char* password = "YourPassword";  // no extra spaces

Fix 2: ESP32 Doesn’t Support 5 GHz Wi-Fi

The ESP32 only supports 2.4 GHz Wi-Fi — it cannot connect to 5 GHz networks at all. Many modern routers broadcast both bands under the same network name, which can cause confusion.

  • Log into your router settings and make sure the 2.4 GHz band is enabled
  • If your router uses the same SSID for both bands, either separate them (e.g. “MyNetwork_2.4”) or check that the router’s band-steering isn’t forcing the ESP32 to 5 GHz
  • Most routers allow you to enable 2.4 GHz only mode for specific devices

Fix 3: Weak Wi-Fi Signal

The ESP32 has a small built-in antenna, and its Wi-Fi reception is more sensitive to distance and obstacles than a smartphone or laptop. If the signal is weak, the board may fail to connect or drop the connection intermittently.

  • Move the ESP32 closer to your router for testing
  • Make sure the board is not inside a metal enclosure — metal blocks Wi-Fi signals
  • Check signal strength with WiFi.RSSI() — values above -70 dBm are fine; below -80 dBm expect issues
Serial.print("Signal strength (RSSI): ");
Serial.println(WiFi.RSSI());
// Good: above -70 dBm | Poor: below -80 dBm

Fix 4: IP Conflict or DHCP Issues

Sometimes the router fails to assign an IP address to the ESP32, or there’s a conflict with another device on the network. Use a static IP to bypass DHCP entirely:

IPAddress local_IP(192, 168, 1, 184);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);

WiFi.config(local_IP, gateway, subnet);
WiFi.begin(ssid, password);

Follow this article for a more in-depth tutorial on how to get a static IP address on your ESP32.

Fix 5: Wrong Wi-Fi Mode in Code

By default, the ESP32 boots in AP+STA mode. Explicitly setting WIFI_STA before WiFi.begin() often resolves connection issues:

#include <WiFi.h>

const char* ssid = "YourSSID";
const char* password = "YourPassword";

void setup() {
  Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("Connected! IP: " + WiFi.localIP().toString());
}

void loop() {}

Fix 6: Power Supply Issues

The ESP32’s Wi-Fi radio draws up to 240 mA during transmission. An underpowered supply will cause resets or failed connections.

  • Always power via the USB port or VIN pin — never rely on the 3.3V pin from a weak source
  • Use a quality USB cable — cheap cables cause voltage drops under load
  • If powering from a battery, ensure it can supply at least 500 mA

For more detail on how to power your ESP32 correctly, follow this article.

Fix 7: Add a Timeout and Reconnect Logic

Infinite while loops waiting for Wi-Fi mask the real problem. Always add a timeout:

WiFi.begin(ssid, password);

int timeout = 0;
while (WiFi.status() != WL_CONNECTED && timeout < 20) {
  delay(500);
  Serial.print(".");
  timeout++;
}

if (WiFi.status() == WL_CONNECTED) {
  Serial.println("Connected! IP: " + WiFi.localIP().toString());
} else {
  Serial.println("Failed to connect. Check SSID, password, and signal.");
}

Frequently Asked Questions

Why does my ESP32 connect in setup() but disconnect during loop()?

This is usually a power issue or the router dropping idle connections. Add reconnect logic in loop() by checking WiFi.status() and calling WiFi.reconnect() when needed.

Does the ESP32 support WPA3?

Most ESP32 variants support WPA2. WPA3 support depends on the chip and firmware version. If your router is WPA3-only, switch it to WPA2/WPA3 mixed mode.

My ESP32 connects but gets no IP address — what’s wrong?

This is typically a DHCP issue. Assign a static IP as shown in Fix 4, or restart your router to clear stale DHCP leases.

Can the ESP32 connect to a hidden SSID?

Yes — use WiFi.begin(ssid, password, channel, bssid, connect) with the BSSID specified, or temporarily make the SSID visible during setup.

Wrapping Up

Most ESP32 Wi-Fi problems come down to wrong credentials, a 5 GHz network, weak signal, a power issue, or a missing WiFi.mode(WIFI_STA) call. Work through the fixes above one by one. And if all else fails, re-flash with a fresh minimal sketch to rule out corrupted firmware.

Next, check out how to create your own Web Server on ESP32!


Thanks for reading!

Links marked with an asterisk (*) are affiliate links which means we may receive a commission for purchases made through these links at no extra cost to you. Read more on our Affiliate Disclosure Page.

Share this article

Leave a Reply

Your email address will not be published. Required fields are marked *