Now, we are going to check whether the ESP8266 and the Arduino IDE are working correctly, and connect your chip to your local Wi-Fi network.
To do so, let's perform the following steps:
// Import required libraries #include <ESP8266WiFi.h> // WiFi parameters constchar* ssid = "your_wifi_name"; constchar* password = "your_wifi_password"; void setup(void) { // Start Serial Serial.begin(115200); // Connect to WiFi WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500);
Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); // Print the IP address Serial.println(WiFi.localIP()); } void loop() { }
You can simply copy the lines of the preceding code and then paste them into the ESP8266 Arduino IDE that you downloaded earlier. Of course, put your own Wi-Fi name and password in the code. Save this file with a name of your choice.
WiFi connected 192.168.1.103
If you can see this message and an IP, congratulations, your board is now connected to your Wi-Fi network! You are now ready to build your first projects using the ESP8266 chip.
3.139.80.209