Serial communication between Arduino Mega2560 and ESP-01

My overall goal is for the ESP-01 to fetch data from the web and send that data to the Arduino Mega board, in which I can display it on an LCD display. I was successful in uploading very basic sketches for the ESP-01 to write data and for the Arduino Mega to read the data.

The issue I am running into is that the ESP-01 doesn’t seem to run its sketch unless the reset pin on the Mega board is set to ground. How I came to suspect that is just by observing if something comes up in the Serial monitor when the reset pin is connected to the ground pin and when the reset pin is not connected to the ground pin. I used the following wiring to test this. However, the the wiring at the bottom of the post is what I want to actually use as I believe TX0 and RX0 are used for the communication between the Mega board and the PC.
TX → TX0
RX → RX0
GND–>GND
CH_PD–>3.3v from Arduino Mega
3v3–>3.3v from Arduino Mega

Why isn’t it running the code even when the Reset pin ISN’T connected to the GND pin on the Arduino Mega board?

Wiring of ESP-01 After Uploading Sketch
TX → D2
RX → D3
GND → GND
CH_PD → 3.3v from Arduino Mega
3v3 → 3.3v from Arduino Mega

I attached the code for the ESP-01 and the Megaboard.

TestESPtoMEGA.ino (275 Bytes)

TestMegatoESP.ino (590 Bytes)

This was an issue with my code for the Arduino Mega

Apparently I cannot send data from the ESP-01 to the Arduino Mega through pins 2 and 3, which was what I was doing. When I changed the pins to 10 and 11, it worked.
"Not all pins on the Mega and Mega 2560 support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69)."

Also during my test runs when I had the RX and TX pins of the ESP-01 in the RX0 and TX0 pins of the Arduino Mega Board, I believe it wasn't working when the reset pin wasn't connected to the Mega board because the TX0 and RX0 pins are used by the Mega board to communicate with the PC. I assume that this prevents the ESP-01 from talking to the PC, so nothing was coming up on my Serial monitor.

Please include your short programs in your next Reply so we don't have to download them. See How to get the best out of the Forum

The Rx and Tx pins on the Mega (pins 0 and 1) are for Serial and are used for communication with the PC and for uploading programs.

You should use Serial1 (pins 19 and 18) or Serial2 (17 and 16) or Serial3 (15 and 14) for communication with your ESP-01

...R