Connecting the ESP8266 to Wi-Fi

What You’ll Need:

  • A Wi-Fi router (2.4GHz) with its SSID and password.
  • An ESP8266 board configured with the Arduino IDE.
#include <ESP8266WiFi.h>


const char* ssid = "YOUR_WIFI_SSID";     // Replace with your network name
const char* password = "YOUR_WIFI_PASS"; // Replace with your network password

void setup() {
  Serial.begin(115200);
  Serial.println();

  Serial.printf("Connecting to %s\n", ssid);
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("\nConnected to Wi-Fi!");
  Serial.printf("IP Address: %s\n", WiFi.localIP().toString().c_str());
}

void loop() {
  
}

 


ESP-01
NodeMCU


19 Nov. 2024 | Last Updated: 22 Nov. 2025 | jaimedcsilva

Related
  • How to Set Up Arduino IDE for ESP8266 Development
  • Blink the Built-in LED
  • Connecting the ESP8266 to Wi-Fi
  • Measuring Wi-Fi Signal Strength (RSSI) with ESP8266
  • ESP-01 ≡ How to program an ESP-01?
  • ESP-01 ≡ Detecting I2C Devices
  • ESP-01 ≡ TX button and an RX LED
  • ESP-01 ≡ Blink external LED on GPIO0
  • NodeMCU ≡ Blink external LED on D0
  • NodeMCU ≡ Detecting I2C Devices

  • Buy Me a Coffee