Forum >Can I send SMS while GPS/GPRS is on?
Can I send SMS while GPS/GPRS is on?

Hi all,
I try to send SMS after reading GPS info and then send the information to server through GPRS,
But when I send the SMS i get
I work based on this code:
https://github.com/DFRobot/GPS-GPRS-GSM ... RS_GPS.ino
any suggestions?
many thanks.

I try to send SMS after reading GPS info and then send the information to server through GPRS,
But when I send the SMS i get
Code: Select all
which mean the operation not allowed.+CMS ERROR: 302
I work based on this code:
https://github.com/DFRobot/GPS-GPRS-GSM ... RS_GPS.ino
any suggestions?
many thanks.

2014-02-25 22:22:56 [quote="Jose"]
let me know if you can keep the GPS while GPRS or SMS is enable without cold resetting.
I'll give it a go in my side.
[/quote]
Yes, I get the GPS coordinates and send them to SMS and GPRS without resetting between GPS and GSM.
^_^
best regards.
wahmalik85
let me know if you can keep the GPS while GPRS or SMS is enable without cold resetting.
I'll give it a go in my side.
[/quote]
Yes, I get the GPS coordinates and send them to SMS and GPRS without resetting between GPS and GSM.
^_^
best regards.

2014-02-25 20:50:32 Great!
I was attempting to get GPS phone calls and GPRS and did not check out that part.
I'm guessing the SMS is working by now in your sketch!
as for the buffer, nice found! not easy to track.
Thanks for sharing!
let me know if you can keep the GPS while GPRS or SMS is enable without cold resetting.
I'll give it a go in my side.
Cheers^^
Jose
I was attempting to get GPS phone calls and GPRS and did not check out that part.
I'm guessing the SMS is working by now in your sketch!
as for the buffer, nice found! not easy to track.
Thanks for sharing!
let me know if you can keep the GPS while GPRS or SMS is enable without cold resetting.
I'll give it a go in my side.
Cheers^^

2014-02-25 03:09:00 Hi,
I found 2 problems I faced.
1- I missed to type double quote (") before ** and after.
what I did is:
the result would be like:
wahmalik85
I found 2 problems I faced.
1- I missed to type double quote (") before ** and after.
what I did is:
Code: Select all
the right is:
Serial.println("777xxxxxx");
Code: Select all
2- the buffer size of serial was to small (64), so I can not send more than 64 character to the Module, so the AT command considered not complete.Serial.println("\"777xxxxxx\"");
the result would be like:
Code: Select all
+CMS ERROR: 302


2014-02-19 21:13:17 Here is the code:
wahmalik85
Code: Select all
#include <Arduino.h> #include <Wire.h> char aux_str[30]; char aux; char latitude[15]; char longitude[15]; char inChar; int index; char inData[200]; char par1 [20]; char par2 [20]; char par3 [20]; char par4 [20]; char par5 [20]; char par6 [20]; int loop_no = 0; /****************************************************************SMS********************/ char phone_no[20]; char inSMS[200]; boolean msgFound = false; /**************************************************************************************/ void setup() { //Init the driver pins for GSM function pinMode(3,OUTPUT); pinMode(4,OUTPUT); pinMode(5,OUTPUT); //Output GSM Timing digitalWrite(5,HIGH); delay(1500); digitalWrite(5,LOW); // Use these commands instead of the hardware switch 'UART select' in order to enable each mode // If you want to use both GMS and GPS. enable the required one in your code and disable the other one for each access. digitalWrite(3,LOW);//enable GSM TX?RX digitalWrite(4,HIGH);//disable GPS TX?RX delay(2000); Serial.begin(9600); delay(5000);//call ready delay(5000); delay(5000); start_GSM(); delay(5000); start_GPS(); delay(500); } void loop() { read_GPS(); delay(2000); /****************************************************************SMS*******************/ SendReadSMSComm(); if(msgFound) { //Serial.println("message will be send"); sendSMS(); delay(1000); DeleteAllMSGs(); } /**************************************************************************************/ if(loop_no > 0 ) { send_GPRS(); }else{ loop_no ++; } delay(15000); msgFound = false; } /****************************************************************SMS********************/ void SendReadSMSComm() { Serial.println("AT"); delay(1000); Serial.println("AT+CMGR=1"); delay(3000); readSMS(); strtok(inSMS, ","); strcpy(phone_no,strtok(NULL, ",")); // Gets ** printBuff(); } void readSMS() { index=0; while(Serial.available() > 0) // Don't read unless // there you know there is data { if(index < 199) // One less than the size of the array { inChar = Serial.read(); // Read a character inSMS[index] = inChar; // Store it index++; // Increment where to write next inSMS[index] = '\0'; // Null terminate the string } } if(index > 20) { msgFound = true; }else{ msgFound = false; } } void DeleteAllMSGs() { Serial.println("AT"); delay(1000); Serial.println("AT+CMGD=1,4"); delay(5000); printBuff(); } void sendSMS() { Serial.println("AT"); delay(1000); //Send message Serial.println("AT+CMGF=1"); delay(1000); Serial.print("AT+CMGS=");//Change the receiver ** Serial.println("777xxxxxx"); delay(1000); Serial.print("lat=");//the message you want to send Serial.print(latitude); Serial.print(",lon="); Serial.print(longitude); delay(1000); Serial.write(26); delay(1000); Serial.println(); printBuff(); } /**********************************************************************************/ void start_GSM(){ //Configuracion GPRS Claro Argentina Serial.println("AT"); delay(2000); //printBuff(); Serial.println("AT+CREG?"); delay(2000); //printBuff(); Serial.println("AT+SAPBR=3,1,\"APN\",\"Fast-Internet\""); delay(2000); //printBuff(); Serial.println("AT+SAPBR=3,1,\"USER\",\"net\""); delay(2000); //printBuff(); Serial.println("AT+SAPBR=3,1,\"PWD\",\"net\""); delay(2000); //printBuff(); Serial.println("AT+SAPBR=3,1,\"Contype\",\"GPRS\""); delay(2000); //printBuff(); Serial.println("AT+SAPBR=1,1"); delay(10000); //printBuff(); Serial.println("AT+HTTPINIT"); delay(2000); //printBuff(); Serial.println("AT+HTTPPARA=\"CID\",1"); delay(2000); //printBuff(); clearBuff(); } void send_GPRS(){ Serial.print("AT+HTTPPARA=\"URL\",\"xxxxx.com/gps/geo2_1.php?lat="); Serial.print(latitude); Serial.print("&lon="); Serial.print(longitude); Serial.print("&par1="); Serial.print(par1); Serial.print("&par2="); Serial.print(par2); Serial.print("&par3="); //Serial.print("ok"); Serial.print(par3); Serial.print("&par4="); //Serial.print("3555"); Serial.print(par4); Serial.print("&par5="); //Serial.print("50251"); Serial.print(par5); Serial.print("&par6="); //Serial.print("0.001"); Serial.print(par6); Serial.println("\""); delay(2000); //waitTillResp(); Serial.println("AT+HTTPACTION=0"); //now GET action delay(2000); //waitTillResp(); clearBuff(); } void start_GPS(){ //Configuracion en Inicializacion GPS Serial.println("AT"); delay(1000); Serial.println("AT+CGPSIPR=9600");// (set the baud rate) delay(1000); Serial.println("AT+CGPSPWR=1"); // ?turn on GPS power supply? delay(1000); Serial.println("AT+CGPSRST=1"); //?reset GPS in autonomy mode? delay(10000); //delay para esperar señal del GPS } void read_GPS(){ Serial.println("AT+CGPSINF=0"); //printBuff(); read_String(); strtok(inData, ","); strcpy(longitude,strtok(NULL, ",")); // Gets longitude strcpy(latitude,strtok(NULL, ",")); // Gets latitude strcpy(par1,strtok(NULL, ",")); strcpy(par2,strtok(NULL, ",")); strcpy(par3,strtok(NULL, ",")); strcpy(par4,strtok(NULL, ",")); strcpy(par5,strtok(NULL, ",")); strcpy(par6,strtok(NULL, ",")); convert2Degrees(latitude); convert2Degrees(longitude); } void read_String() { index=0; while(Serial.available() > 0) // Don't read unless // there you know there is data { if(index < 199) // One less than the size of the array { inChar = Serial.read(); // Read a character inData[index] = inChar; // Store it index++; // Increment where to write next inData[index] = '\0'; // Null terminate the string } } } int8_t convert2Degrees(char* input){ float deg; float minutes; boolean neg = false; //auxiliar variable char aux[10]; if (input[0] == '-') { neg = true; strcpy(aux, strtok(input**, ".")); } else { strcpy(aux, strtok(input, ".")); } // convert string to integer and add it to final float variable deg = atof(aux); strcpy(aux, strtok(NULL, '\0')); minutes=atof(aux); minutes/=1000000; if (deg < 100) { minutes += deg; deg = 0; } else { minutes += int(deg) % 100; deg = int(deg) / 100; } // add minutes to degrees deg=deg+minutes/60; if (neg == true) { deg*=-1.0; } neg = false; if( deg < 0 ){ neg = true; deg*=-1; } float numeroFloat=deg; int parteEntera[10]; int cifra; long numero=(long)numeroFloat; int size=0; while(1){ size=size**; cifra=numero%10; numero=numero/10; parteEntera[size-1]=cifra; if (numero==0){ break; } } int indice=0; if( neg ){ indice++; input[0]='-'; } for (int i=size-1; i >= 0; i--) { input[indice]=parteEntera[i]+'0'; indice++; } input[indice]='.'; indice++; numeroFloat=(numeroFloat-(int)numeroFloat); for (int i=1; i<=6 ; i++) { numeroFloat=numeroFloat*10; cifra= (long)numeroFloat; numeroFloat=numeroFloat-cifra; input[indice]=char(cifra)+48; indice++; } input[indice]='\0'; } /*****************************/ void clearBuff(){ while( Serial.available() > 0) { Serial.read(); // Clean the input buffer } } void printBuff() { delay(1000); while( Serial.available() > 0) { Serial.print((char)Serial.read()); } Serial.println(""); delay(1000); clearBuff(); } void waitTillResp(){ int d = 0; while(Serial.available() < 1 && d != 10){ delay(1000); d++; } printBuff(); }

2014-02-19 00:53:44 I suggest you to check if you still have your services enabled, and try to send a sms manually before testing automatically from Arduino.
Could be that the SMS is not enabled, or the command is malformed.
Best if you send the code / sketch to see where it could be the problem or to try it
Jose
Could be that the SMS is not enabled, or the command is malformed.
Best if you send the code / sketch to see where it could be the problem or to try it
