I am connecting the ESP8266 to Wi-Fi using this code. When I run the code as is, things get printed to my Serial Monitor. However, when I replace ssid and password with the SSID and password of my Wi-Fi network, nothing gets printed.
I am not sure why this is happening. All I modified was the SSID and password and now nothing gets printed. Even if I add a print statement before WiFi.begin(), nothing gets printed.
What steps should I take to fix this?
Thanks.
#include <ESP8266WiFi.h> // Include the Wi-Fi library
const char* ssid = "SSID"; // The SSID (name) of the Wi-Fi network you want to connect to
const char* password = "PASSWORD"; // The password of the Wi-Fi network
void setup() {
Serial.begin(115200); // Start the Serial communication to send messages to the computer
delay(10);
Serial.println('\n');
WiFi.begin(ssid, password); // Connect to the network
Serial.print("Connecting to ");
Serial.print(ssid); Serial.println(" ...");
int i = 0;
while (WiFi.status() != WL_CONNECTED) { // Wait for the Wi-Fi to connect
delay(1000);
Serial.print(++i); Serial.print(' ');
}
Serial.println('\n');
Serial.println("Connection established!");
Serial.print("IP address:\t");
Serial.println(WiFi.localIP()); // Send the IP address of the ESP8266 to the computer
}
void loop() { }
Did you set the baud rate of the serial monitor to 115200 as specified in your sketch, the image you uploaded shows it at 9600?
You can change it with the drop down menu in the serial monitor window.
I changed the baud rate, but I have the same issue when using both 115200 and 9600. I made sure to change the baud rate of the serial monitor to the baud rate in my code.
Its hard to start the serial monitor when the program first runs; If you increase the delay from 10msec to a few seconds it will give you time to start the serial monitor and you should then see the "connecting to".
Clearly its not connecting - because the SSID etc is not correct.
What do you see if you put the right SSID and password, with the longer delay? You should at least see "connecting to" etc.