Before getting started, make sure you have:
- A Wi-Fi router (2.4GHz only, ESP8266 does not support 5GHz)
- Your network SSID (Wi-Fi name)
- Your password
#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() {
}
Expected Output
If everything works correctly, you should see something like:
Connecting to MyWiFi
.......
Connected to Wi-Fi!
IP Address: 192.168.1.45
ESP