Hello all. Nice forum!
I am new to arduino programming and electronics. So I am having problem trying to figure out what to put where.
Please tell me if there is anything to be done to improve and also if there is any mistakes in code or poor programming practice.
I have an arduino mega 2560 board connected to a GSM sim 900 module. I need to send text messages from the GSM module.
Hardware connections: VCC of GSM connected to 5Vpin of mega. V interface pin of GSM is supplied with same voltage as microcontroller (from Vin pin of mega) as specified in its manual. TXD of GSM is connected to RX3 of arduino and RXD of GSM to TX3 of mega board.
Problem :
I am able to send blank text messages with the program I have. But when I insert a new statement to enter text into message body, GSM module do not send message. The instructions to be send to GSM modem is:
AT+CMGF=1 // for setting GSM modem to text message mode
AT+CMGS="<phone number>" text message <enter>
This is the program I used:
char mobileno[]="+xxxxxxxxxxxx";
void setup()
{
Serial.begin(115200); //For pc and arduino communication.
Serial3.begin(115200); // Gsm Modem baud rate
}
void loop()
{
Serial3.println("AT+CMGF=1"); // to set in text mode
delay(800);
Serial3.print("AT+CMGS=");
Serial3.write(34); //34 is the ASCII value for "
for(int i=0;i<13;i++)
{
Serial3.print(mobileno[i]);
}
Serial3.write(34); // 34= ASCII for double quotes
Serial3.println();
Serial3.print("Text message"); // This is the new statement inserted. GSM doesn't send message when this is inserted.
Serial3.println();
delay(1000);
Serial3.write(26); // 26=ASCII for enter
delay(800);
}
Do I have to print the text message some where else? Or is there any mistake in this code? Any pointers would be much appreciated.
