Receiving an SMS then sending another one back ... GPS/GPRS/GSM_Module_V3.0

Like the title show,
what i am trying to do is send an SMS from my mobile phone to the robot.. then i want it to send a reply message to my phone..
Is there a way to switch between the commands.
I am using Arduino Mega, i can send SMS and receive SMS to control the board actions, but i cant do them both at the same time......
Thanks
This is the code i tried
what i am trying to do is send an SMS from my mobile phone to the robot.. then i want it to send a reply message to my phone..
Is there a way to switch between the commands.
I am using Arduino Mega, i can send SMS and receive SMS to control the board actions, but i cant do them both at the same time......
Thanks

This is the code i tried
Code: Select all
byte gsmDriverPin[3] = {
3,4,5};
char inchar;
void set_GSM(){
//Init the driver pins for GSM function
for(int i = 0 ; i < 3; i++){
pinMode(gsmDriverPin[i],OUTPUT);
}
digitalWrite(5,HIGH);//Output GSM Timing
delay(1500);
digitalWrite(5,LOW);
digitalWrite(3,LOW);//Enable the GSM mode
digitalWrite(4,HIGH);//Disable the GPS mode
delay(2000);
Serial.begin(9600); //set the baud rate
delay(5000);//call ready
delay(5000);
delay(5000);
}
//SMS
void set_Message(){
Serial.println("AT"); //Send AT command
delay(2000);
Serial.println("AT");
delay(2000);
//Send message
Serial.println("AT+CMGF=1");
delay(1000);
Serial.println("AT+CMGS=\"744XXXX\"");
delay(1000);
}
void smsUser(){
Serial.print("Hi there");//THE SOFTWARE SMS
delay(1000);
Serial.write(26);
}
void setup()
{
//Init the driver pins for GSM function
for(int i = 0 ; i < 3; i++){
pinMode(gsmDriverPin[i],OUTPUT);
}
pinMode(ledpin,OUTPUT);
Serial.begin(9600); //set the baud rate
digitalWrite(5,HIGH); //Output GSM Timing
delay(1500);
digitalWrite(5,LOW);
digitalWrite(3,LOW); //Enable the GSM mode
digitalWrite(4,HIGH); //Disable the GPS mode
delay(2000);
delay(5000); //call ready
delay(5000);
Serial.println("AT+CMGD=1,4"); //Delete all SMS in box
}
void loop()
{
if(Serial.available()>0)
{
inchar=Serial.read();
if(inchar=='T')
{
delay(10);
inchar=Serial.read();
if (inchar=='I') //When the GSM module get the message, it will display the sign '+CMTI "SM", 1' in the serial port
{
delay(10);
Serial.println("AT+CMGR=1"); //When Arduino read the sign, send the "read" AT command to the module
delay(10);
}
}
else if (inchar=='L')
{
delay(10);
inchar=Serial.read();
if (inchar=='H') //Thw SMS("LH") was display in the Serial port, and Arduino has recognize it.
{
set_GSM();
set_Message();
smsUser();
Serial.println("AT+CMGD=1,4"); //Delete all message
delay(500);
}
}
}
}
2015-10-23 06:47:16 Hello MMAB,
I wnat to ask you..I have a problem to get GPS location..What I am trying to do is send SMS from my mobile phone to the module v3..then I want it to send a reply message with GPS location to my mobile phone..
you have solved the problem?
aliabulolipop123
I wnat to ask you..I have a problem to get GPS location..What I am trying to do is send SMS from my mobile phone to the module v3..then I want it to send a reply message with GPS location to my mobile phone..
you have solved the problem?

2014-08-11 18:09:17 Uhm~ almost. It is just a data analysis.
You can define your symbol, like a string, a char or something else.
With if...else sentence to realize some function.
Hey, If you want to get the GPS location, the last sample code maybe will help you, it will send a message includes its Location in the SMS.
Grey.CC
You can define your symbol, like a string, a char or something else.
With if...else sentence to realize some function.
Hey, If you want to get the GPS location, the last sample code maybe will help you, it will send a message includes its Location in the SMS.

2014-08-09 04:46:31 Thanks for the quick reply Grey,
but what if i want to send back the GPS location of the robot....
would i follow the same method, but just change the code within the
Thanks again!
MMAB
but what if i want to send back the GPS location of the robot....
would i follow the same method, but just change the code within the
Code: Select all
to the code used to get the GPS location ?!?!?!if (inchar=='H'){.....
Thanks again!

2014-08-08 18:49:33 Really?
This is code which I wrote before. Although it is very low, but it could work before.
You could check it first.
Next time, maybe I can modify the code , make better.
Grey.CC
This is code which I wrote before. Although it is very low, but it could work before.
You could check it first.
Code: Select all
When you send a message "H" to GSM module, it will turn on the LED, and sending back a SMS "I am ON" byte gsmDriverPin[3] = {
3,4,5};//The default digital driver pins for the GSM and GPS mode
//If you want to change the digital driver pins
//or you have a conflict with D3~D5 on Arduino board,
//you can remove the J10~J12 jumpers to reconnect other driver pins for the module!
int ledpin = 8;
char inchar;
void setup()
{
//Init the driver pins for GSM function
for(int i = 0 ; i < 3; i++){
pinMode(gsmDriverPin[i],OUTPUT);
}
pinMode(ledpin,OUTPUT);
Serial.begin(9600); //set the baud rate
digitalWrite(5,HIGH); //Output GSM Timing
delay(1500);
digitalWrite(5,LOW);
digitalWrite(3,LOW); //Enable the GSM mode
digitalWrite(4,HIGH); //Disable the GPS mode
delay(2000);
delay(5000); //call ready
delay(5000);
Serial.println("AT+CMGD=1,4"); //Delete all SMS in box
}
void loop()
{
if(Serial.available()>0)
{
inchar=Serial.read();
if(inchar=='T')
{
delay(10);
inchar=Serial.read();
if (inchar=='I') //When the GSM module get the message, it will display the sign '+CMTI "SM", 1' in the serial port
{
delay(10);
Serial.println("AT+CMGR=1"); //When Arduino read the sign, send the "read" AT command to the module
delay(10);
}
}
else if (inchar=='L')
{
delay(10);
inchar=Serial.read();
if (inchar=='H') //Thw SMS("LH") was display in the Serial port, and Arduino has recognize it.
{
delay(10);
digitalWrite(ledpin,HIGH); //Turn on led
delay(50);
Serial.println("AT+CMGD=1,4"); //Delete all message
delay(500);
Serial.println("AT+CMGF=1");
delay(500);
Serial.println("AT+CMGS=\"15xxxxxxxxx\"");//Change the receiver phone number
delay(500);
Serial.print("I am ON");//the message you want to send
delay(500);
Serial.write(26);
delay(500);
}
if (inchar=='L') //Thw SMS("LH") was display in the Serial port, and Arduino has recognize it.
{
delay(10);
digitalWrite(ledpin,LOW); //Turn off led
delay(50);
Serial.println("AT+CMGD=1,4"); //Delete all message
delay(500);
Serial.println("AT+CMGF=1");
delay(500);
Serial.println("AT+CMGS=\"15xxxxxxxxx\"");//Change the receiver phone number
delay(500);
Serial.print("I am OFF"); //the message you want to send
delay(500);
Serial.write(26);
delay(500);
}
}
}
}
Next time, maybe I can modify the code , make better.
