0
0
Arduinoprogramming~30 mins

WiFi with ESP8266/ESP32 in Arduino - Mini Project: Build & Apply

Choose your learning style9 modes available
WiFi with ESP8266/ESP32
📖 Scenario: You want to connect your ESP8266 or ESP32 microcontroller to a WiFi network so it can communicate with other devices or the internet.
🎯 Goal: Build a simple Arduino program that connects your ESP8266/ESP32 to a WiFi network and prints the connection status and IP address to the Serial Monitor.
📋 What You'll Learn
Create variables for WiFi network name and password
Initialize WiFi connection using the variables
Check connection status in a loop until connected
Print connection status and IP address to Serial Monitor
💡 Why This Matters
🌍 Real World
Connecting ESP8266 or ESP32 to WiFi is the first step to making smart devices that can send data to the internet or be controlled remotely.
💼 Career
Understanding how to connect microcontrollers to WiFi networks is essential for IoT developers and embedded systems engineers.
Progress0 / 4 steps
1
Set up WiFi network credentials
Create two variables called ssid and password and set them to the exact strings "YourNetworkName" and "YourNetworkPassword" respectively.
Arduino
Need a hint?

Use const char* type for the network name and password strings.

2
Start Serial and WiFi connection
Add void setup() function. Inside it, start Serial communication at 115200 baud with Serial.begin(115200);. Then start WiFi connection using WiFi.begin(ssid, password);.
Arduino
Need a hint?

Use Serial.begin(115200); to start serial and WiFi.begin(ssid, password); to start connecting.

3
Wait for WiFi connection
Inside void setup(), add a while loop that waits until WiFi.status() == WL_CONNECTED. Inside the loop, print "Connecting to WiFi..." to Serial and add a 500 ms delay.
Arduino
Need a hint?

Use while loop to check connection status and delay(500); to wait half a second each time.

4
Print connection success and IP address
After the while loop in setup(), print "WiFi connected!" and then print the IP address using WiFi.localIP() with Serial.println().
Arduino
Need a hint?

Use Serial.println("WiFi connected!"); and Serial.println(WiFi.localIP()); to show the IP address.