With the Code below I get the following output in the serial monitor. Notice how it doest print the full message in the serial monitor (missing " Hi!") and more importantly this code does not send anything via sms. If anyone knows why this is please help me, thank you ![]()
Setting AT commands to text mode...
Trying to send to number...
Writing message...
Message should be sent!AT+CMGF=1
AT+CMGS="+61xxxxxxxxx"
SIM900 and Arduino say
void setup()
{
Serial1.begin(19200); //Default serial port setting for the GPRS modem is 19200bps
Serial.begin(19200); // the GPRS baud rate
delay(500);
}
void loop()
{
//after start up the program, you can using terminal to connect the serial of gprs shield,
//if you input 't' in the terminal, the program will execute SendTextMessage(), it will show how to send a sms message,
if (Serial.available())
switch(Serial.read())
{
case 't':
SendTextMessage();
break;
}
if (Serial1.available())
Serial.write(Serial1.read());
}
void SendTextMessage()
{
Serial1.println("\r");
delay(1000); //Wait for a second while the modem sends an "OK"
Serial.println("Setting AT commands to text mode...");
Serial1.println("AT+CMGF=1\r"); //Because we want to send the SMS in text mode
delay(1000);
//Serial1.print("AT+CSCA=\"+61xxxxxxxxx\"\r\n"); //Setting for the SMS Message center number,
//delay(1000); //uncomment only if requiredh
Serial.println("Trying to send to number...");
Serial1.println("AT+CMGS=\"+61xxxxxxxxx\"\r"); //Start accepting the text for the message
//to be sent to the number specified.
//Replace this number with the target mobile number.
delay(1000);
Serial.println("Writing message...");
Serial1.print("SIM900 and Arduino say Hi!\r"); //The text for the message
delay(1000);
//Serial.print(26,BYTE); //Equivalent to sending Ctrl+Z
Serial1.write(26);
//Serial1.println((char)26);
Serial.println("Message should be sent!");
Serial1.println();
}
