ESP32 Wi-Fi Station Mode Not Connecting
DodaTech
Updated 2026-06-26
1 min read
In this tutorial, you'll learn about ESP32 Wi. We cover key concepts, practical examples, and best practices.
The Problem
ESP32 cannot connect to Wi-Fi in station mode — connection timeout, wrong credentials, or AP not found.
Quick Fix
Wrong
#include <WiFi.h>
void setup() {
WiFi.begin("MyNetwork", "password");
while (WiFi.status() != WL_CONNECTED) {}
}
ets Jun 8 2016 rst:0x1 (POWERON),boot:0x13 (SPI_FAST_FLASH_BOOT)
[W][WiFiClient.cpp:254] connect(): hostname not found
Right
#include <WiFi.h>
const char* ssid = "MyNetwork";
const char* pass = "password123";
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); }
Serial.println(WiFi.localIP());
}
. . . . . .
Connected! IP: 192.168.1.42
Prevention
Always verify SSID and password match the router. Add a connection timeout (20 attempts max). Keep credentials in a separate config file. Enable WiFi.setAutoReconnect(true) for automatic recovery. Use WiFi.status() checks before sending data.
DodaTech engineers apply these same patterns when building Doda Browser's networking stack, DodaZIP's firmware packaging pipeline, and Durga Antivirus Pro's sensor communication layer.
FAQ
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro