GPS/GPRS/GSM Shield V3.0 (sim908) send data to server through TCP

Hi guys, I’m currently using GPS/GPRS/GSM Shield V3.0 (sim908) with ARDUINO UNO R3 to send GPS data to server using TCP.

But I can only found some open source code using HTTP. So, I got no idea how to do it using AT command.

Hope I can get some guidance from you guys. Thanks.
Below will be the code using HTTP.

char aux_str[30];
char aux;

char latitude[15];
char longitude[15];

char inChar;
int index;
char inData[200];


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); 
    
    Serial.begin(9600);
        // 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(20000);
    
    start_GSM();
    
    delay(5000);
    
    start_GPS();
  
    
 }
 void loop()    
 {    
   
   
   read_GPS();
   delay(2000);
   send_GPRS();
   delay(30000);

 }
 
 void start_GSM(){
     //Configuracion GPRS Claro Argentina
    Serial.println("AT");
    delay(2000);
    Serial.println("AT+CREG?");
    delay(2000);
    Serial.println("AT+SAPBR=3,1,\"APN\",\"m2minternet\"");
    delay(2000);
    Serial.println("AT+SAPBR=3,1,\"USER\",\"\"");
    delay(2000);
    Serial.println("AT+SAPBR=3,1,\"PWD\",\"\"");
    delay(2000);
    Serial.println("AT+SAPBR=3,1,\"Contype\",\"GPRS\"");
    delay(2000);
    Serial.println("AT+SAPBR=1,1");
    delay(10000);
    Serial.println("AT+HTTPINIT");
    delay(2000);
    Serial.println("AT+HTTPPARA=\"CID\",1");
    delay(2000);
 }
 
 void send_GPRS(){
          
          Serial.print("AT+HTTPPARA=\"URL\",\"http://loocasia.com:30175");
          Serial.print("&latitude=");
          Serial.print(latitude);
          Serial.print("&longitude=");
          Serial.print(longitude);
          Serial.println("\"");
          delay(2000);
          Serial.println("AT+HTTPACTION=0"); //now GET action
          delay(2000);
          
          
 }
 
 
 void start_GPS(){
     //Configuracion en Inicializacion GPS
    Serial.print("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");
    
    read_String();
    
    strtok(inData, ",");
    strcpy(longitude,strtok(NULL, ",")); // Gets longitude
    strcpy(latitude,strtok(NULL, ",")); // Gets latitude
    
    
    
    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+1, "."));

    }
    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+1;
        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';


}

GPS/GPRS/GSM Shield V3.0 (sim908)

Link?

Also, while I'll be the first to admit that I'm not the brightest at this time of day, I don't understand your question. That code you posted is just AT commands and overall appears to be correct.

Sorry for my language problem.
The code that I attached is using HTTP, but now my server only accept TCP connection.

This is the link of the shield that I using with Arduino Uno
http://www.dfrobot.com/index.php?route=product/product&product_id=673#.VZJLZfmqqko

This is the TCP code I that I tried but my server not getting anything.

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!
void setup()
{    
  //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
}
 
void loop()
{  
  Serial.println("AT"); //Send AT command  
  delay(2000);
  Serial.println("AT");  
  delay(2000);
  //Send message
  Serial.println("AT+CPIN?");
  delay(2000);
  Serial.println("AT+CREG? ");  
  delay(2000); 
  Serial.println("AT+CGATT?"); 
  delay(2000);
  Serial.println("AT+CIPSTATUS");
  delay(2000);
  Serial.println("AT+CIPMUX=0");
  delay(2000);
  Serial.println("AT+CSTT=\"m2minternet\",\"\",\"\"");
  delay(2000);
  Serial.println("AT+CIICR");
  delay(2000);
  Serial.println("AT+CIPSTART=\"TCP\",\"66.226.75.158\",\"30175\"");
  delay(2000);
  Serial.println("AT+CIPSEND=\"90\"");
  delay(2000);
  Serial.println("$FRCMD,1234,_SendMessage,,0120.40000,N,10314.40000,E,0.0,21.60,10.0,300615,075018.000,1*5E");//the message I want to send
  delay(2000);
  //Serial.write(26);
  //while(1);
}

Thanks for your reply.

Hi,

I had my diploma project with this module one month ago and I know how you can deal with this problem. I don't have time to understood your code but I will give a hint, maybe you will find helpful.

But in my case I used only the HTTP sessions.

To receive data into a server, you can simply use HTTP initiation from SIM908, sending a request to a PHP page using the GET PHP method, like this: http://goo.gl/TaAuoj (look at the url from the browser page).

Those data coordinates are save then into a txt file and with other php data you can read the last line and show the information using an API from Google Maps.

Firstly you need to activate the GPRS internet on SIM908 doing:  GPRS Attach (it's automaticaly done but you can do it with AT+CGATT=1 command)  PDP context activation

Then set-up the APN (you must have knowledge about PDP context activation for this): AT+CGDCONT=1,"IP","live.vodafone.com","0.0.0.0",0,0

Connecting to the fist PDP profile: AT+CGACT=1,1

Get the address from DHCP server: AT+CGPADDR=1;

Set up the bearer: AT+SAPBR=3,1,"APN","live.vodafone.com"

Initiate a HTTP session: AT+HTTPINIT;

Sending the data from microcontroler requesting a PHP page like this: AT+HTTPPARA="URL","http://www.yoursite.com/data.php?lat itude=42.41472&longitude=22.16417&altitude=37&speed=80"

Sending the parameters using the first bearer. AT+HTTPPARA="CID",1;

Sending the HTTP page request. AT+HTTPACTION=0;

you can read the answer from the php page with AT+HTTPREAD; if is necessary.

In my project I got helped from this site:

http://m2msupport.net/m2msupport/software-and-at-commands-for-m2m-modules/