Trouble connecting to Wi-Fi using ESP8266

Hello.

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() { }

Define "nothing."

When I view Serial Monitor, I see a white screen with no text as shown here.

There are 3 sketches presented at your link.
I wonder which you're meaning.

I'd give you the "use code tags" schpeel and all - but what's the use?

Sorry about that. I am talking about the first piece of code labelled "Station Mode - Connecting to one specific network".

I added the code to the post above.

I see the serial monitor. Did you select a board and port? Show the whole IDE.

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.

This is a clue:
image

Yes, I have selected a board (NodeMCU ESP-12E) and port (COM6). This is the whole IDE.

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.

Can you show us an image of the serial monitor when that happens so we can see what "things" get printed?

Absolutely.

When I run this, "Connecting to " and the first five values of i (0-4) are not printed.

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.