Communication with ESP8266

Hello

I recently bought an ESP8266.

I can communicate with it normally by uploading an empty sketch to my Arduino Mega and using the serial monitor but whenever I try communicating with it inside a sketch, the light on the ESP doesn't even flash like if it wasn't receiving my commands.

I'm using an external 3V 2A power supply for my ESP so no issue there.

Anyone have any ideas about my problem?

Did I just buy a bad module?

post your sketch.