# GSM SIM-300 read msg problem

I'm unable to get a proper response from my GSM modem300, sometimes it responds with nothing, sometimes it replies half of line of ONE message from full inbox, sometimes it just sends the command (AT+CMGR=1) I just sent, back many times.

Print screens:

I'm using Arduino, directly connecting the Tx and Rx of board to Rx and Tx of arduino, and GND to Arduino GND.

CODE:

char incomingByte=0;
void setup()
{
Serial.begin(9600);
delay(2000);
Serial.println("AT+CMGF=1");
delay(2000);
Serial.println("AT+CMGR=1");
delay(2000);
}

void loop()
{
while (Serial.available() > 0)
{
if(incomingByte!='\n'){ Serial.print(incomingByte); }
if(incomingByte=='\n'){ Serial.print(incomingByte); }
}
}


It might be worth mentioning that, I can send messages properly, and make and receive calls with no problem.

• responds with half line of one message from FULL inbox!: imgur.com/zsmDcIc – user280353 Jan 14 '14 at 10:17
• responds with garbage: imgur.com/vTVSwyf – user280353 Jan 14 '14 at 10:18
• sorry to do this, -_-' site won't let me post more than 2 links. – user280353 Jan 14 '14 at 10:19
• Instead of posting links of images of GUI windows of text, could you cut & paste the text? Use small representative samples (not pagefulls) – RedGrittyBrick Jan 14 '14 at 10:23
• You are reading from serial in incomingByte and sending same byte on same serial! I am bit suspicious about this! And Not about problem, But You are doing same thing in if(incomingByte != '\n')  and if(incomingByte == '\n') ... Why to write two conditions! – Swanand Jan 14 '14 at 10:24

By using the same serial port to communicate with a modem and to communicate with your PC, you are causing confusion.

• You are echoing the modem's reply back to the modem.
• Modems usually echo commands back to you.

I'd use separate channels as shown in the Arduino serial tutorial.

Last time I did something like this (with an Arduino communicating with a MIDI serial device) I used a 16x2 LCD to display what was being received. But you could use software serial if you prefer (or don't have a character LCD)

• Thanks GrittyBrick, I've tried software serial in a different way, now I'll try it again with the same code design and see what happens. If it works I'll let you know. – user280353 Jan 14 '14 at 10:54
• Still no luck, this is the reply: f~`8AT+CMGR=1 +CMGR: "REC READ","52266001",,"08/08/19,12:09:0 – user280353 Jan 14 '14 at 11:36
• no message body, not even other message headers – user280353 Jan 14 '14 at 11:39
• What happens if you replace the GSM modem with a wire link? Back in the day, we used to use a Peripheral And Processor Electronic Reactive Communications Link Interface Probe (P.A.P.E.R.C.L.I.P.) – RedGrittyBrick Jan 14 '14 at 11:54
• Getting the command replied back to me on hardware Serial, but on Software Serial I'm getting gibberish; diff baud rates too. – user280353 Jan 14 '14 at 12:31