Serial Monitor Not printing with ESP-01

My serial monitor does not display anything and I've tried every solution I found online but nothing seems to work
Can someone help me out? what seems to be the problem??

#include <ESP8266WiFi.h>

const char* ssid = "WED6FDGBgo"; // Your Wi-Fi Name

const char* password = "1ala21SFES308929"; // Wi-Fi Password

int Direction = 1; // motor connected to GPIO1 (Tx pin)

WiFiServer server(80); //HTTP server

void setup()

{
Serial.begin(115200); //Default Baudrate
delay(1000);

digitalWrite(Direction, LOW);

while (! Serial);
Serial.print("Connecting to the Newtork");

WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED)

{

delay(500);

Serial.print(".");

}

Serial.println("WiFi connected");

server.begin(); // Starts the Server

Serial.println("Server started");

Serial.print("IP Address of network: "); // will IP address on Serial Monitor

Serial.println(WiFi.localIP());

Serial.print("Copy and paste the following URL: https://"); // Will print IP address in URL format

Serial.print(WiFi.localIP());

Serial.println("/");

}

Recommendations.
Read: How to get the best out of this forum
Use </> tags to post sketcks or printouts;
Post your scheme. Can be done freehand;

RV mineirin

Have you set the baud rate of the serial monitor to 115200?

yes and in the tools too, its all the same
I read somewhere that after uploading the code I should press reset button on my ESP, but its a pin in esp-01 so I connected it to a switch and after uploading I press the button and the serial monitor prints out gibberish
I also tried connecting it to GND and VCC and nth changed

Where exactly does the switch connect the reset pin to ?

I connected one end of the switch to GND and the other end to the RST pin
here's my serial monitor before and after pressing


AFTER

There is always one line of gibberish after the esp is reset.

Question: why haven't you fixed the code tags in your first post yet?

Forget you sketch for now and try just a Serial.println("Hello World"); in loop(), perhaps with a delay(1000); in there too

Hi @hanaalaa .
Please do this test.
This garbage-looking printed msg is the ESP control msg after reset, printing at 57600 or 74880 bps.
Just for testing, change your serial monitor to 57600 (or 74880) and see what appears printed.

RV mineirin

should I also change the baudrate in my code and tools?

Hi .
it is not necessary for this test but you can change it if you want.

RV mineirin

The serial monitor still prints nothing even after changing the baudrate

Post a photo of your dev board. What happens if you disconnect the cable (power off), connect it back, then open the serial port?

ESP8266-Pinout
this is the one I'm using (Different color tho)
My connections are:
Tx-RxD(of the TTL)
Rx-TxD(of the TTL)
CH-EN-3.3V
GPIO0-GND
GPIO2-Vcc (to program in UART mode because my project requires interfacing with UART)
Vcc-3.3v
GND-GND

What happens if you disconnect the cable (power off), connect it back, then open the serial port?
Ans: when I do so the serial monitor still prints out nothing

It worked actually, kept printing hello world every one second

Good. So you can print to Serial and the problem is in your sketch or how you are using it

Upload your sketch then open the Serial monitor and with it still open disconnect the power to the ESP and reconnect it. Does anything appear on the Serial monitor ?

turns out the problem was in my loop function, but my code still prints sometimes and other times it doesn't what could be the problem?
for example I copy pasted this exact code: ESP8266 Node MCU Handling HTML web forms data | Circuits4you.com
but me serial monitor doesn't print even tho it printed a while ago, weird!