drled:
void loop() {
if(Serial.available() > 0)
{
gsm_char = Serial.read();
//Evaluate input.
if(gsm_char=='t')//Checks input char = t
{
Serial.println("t received");
gsmSerial.print("AT\r\n"); //Send AT TO GSM module
delay(500); // wait a moment
gsm_char = gsmSerial.read();
Serial.println(gsm_char);
}
}
}
You may try waiting for a longer "moment". Instead of 500 you could put 5000, yes five seconds, at least once.
I notice you use print("AT\r\n"): why not println("AT")? Maybe you are right in doing so, but since the sequence \r\n (cr-lf) is often confusing in AT commands you may also try print("AT\r") and print("AT\n").
There is a logic in the program's behavior (perhaps not the one you intended): after sending the command and waiting for 1/2 sec you read a character from the gsm without checking for gmsSerial.available() first. So if there is no answer gsmSerial.read() will return -1, translated by the serial monitor into that glyph (try Serial.println(gsm_char, DEC) to see its value as a number).