I just got a new Sim900 and connected to an Arduino Uno. I used the code below to send a text to myself. I received the text on my cell, but I did not receive any echo on my serial monitor (ie. "OK"). I have tried swapping the RX/TX pins and different baud rates with no success.
void setup()
{
Serial.begin(9600); //Baud rate of the GSM/GPRS Module
Serial.println("");
delay(2000);
Serial.println("AT+CMGF=1");
delay(1000);
Serial.println("AT+CMGS=\"+120########\""); //Number to which you want to send the sms
delay(1000);
Serial.print("This is a test."); //The text of the message to be sent
delay(1000);
Serial.write(0x1A); // send CTRL - z to end message
Serial.write(0x0D); // Carriage Return
Serial.write(0x0A); // Line Feed
delay(5000);
}
void loop()
{
}
You should never, never, ever use
delayas a substitute for reading and parsing the response sent back from the modem. Now, I do recognize that this is a bit ironic advice since the problem is that you do not get any response, but never the less you should throw away this code using delay the very moment you get response working, not a second later.Just to emphasise this point, after sending an AT command line to the modem you should not send anything before the modem responds with a final result code. The V.250 standard says:
If you send anything before receiving the final result code you will abort the currently executing command!
I do not know this sim900 modem, but notice that modems in general can be configured to not echo characters and suppress result codes (
ATEandATQcommands), so unless you know absolutely for sure that the modem is configured to echo characters and print result codes this should be your first thing to check.All this is described in the V.250 standard, which is a really important document. Read all of chapter 5 and also pay close attention to chapter 6.2 DTE-DCE interface commands.
Mobile phone related commands are generally specified in the 27.007 standard, although sms message related commands are specified in 27.005 standard. Do pay close attention to the fact that for
AT+CMGSin particular you need to wait to receive `"\n\r> " before sending the sms payload (see also the first part of this answer).