Arduino serial port won't communicate with ESP8266

I have an ESP8266 connected to my arduino, and if I hold the reset button, I can talk to the ESP over serial terminal by typing AT commands on my laptop. I see the little blue LED flash with every command, and the ESP responds perfectly and can connect to the internet. But when I stop holding the reset button and my arduino runs code to try to talk to the ESP, it doesn’t work. The blue light on the ESP doesn’t even flash, despite that the commands I’m trying to send show up in my serial terminal, and the little yellow TX light on the arduino flashes. Any advice? My code is below.

#include <Wire.h> // Serial library

void setup() {

Serial.begin(115200); // Communication with ESP8266 via 5V/3.3V level shifter
Serial.setTimeout(5000); // Set the timeout value for the ESP8266
delay(5000); // Delay to complete setup

}

void loop() {

Serial.println(“AT”); // Send “AT” to the ESP 10 times/second
delay(100);
}

You did not mention which Arduino board you are using, but you should put the ESP8266 on it's own serial port, either a hardware serial if a Mega, or software serial on an Uno.

ESP8266 modules need their own 3.3V power.

If your ESP8266 module's default baud rate is 115200, you will need to leave it unconnected when uploading a sketch to your Arduino, then reconnect back to pins 0/1. This is assuming you are using an Arduino Uno or any other variety with just one hardware serial port.