General

GPS/GPRS/GSM Shield V3.0 (Arduino Compatible) TCP Connection

userHead 13053167 2015-07-02 17:34:35 10433 Views4 Replies
Hi guys , I'm using GPS/GPRS/GSM Module V3.0 with Arduino UNO to send message to my server using TCP protocol. But I could only find some codes that using HTTP protocol. I have tried to write some codes but my server is not receiving anything and my server can only accept TCP connection.

Below is the code that I wrote myself with reference to other example codes found in the internet.

Code: Select all
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+CGPSPWR=1\r\n");
  delay(2000);
  while(Serial.available()){
    char x = Serial.read();
    Serial.print(x);
  }
  delay(2000);
 
  Serial.println("AT+CGPSRST=1\r\n");
  delay(2000);
  while(Serial.available()){
    char x = Serial.read();
    Serial.print(x);
  }
  delay(2000);
 
  Serial.println("AT+CFUN=1\r\n");
  delay(2000);
  while(Serial.available()){
    char x = Serial.read();
    Serial.print(x);
  }
  delay(2000);
 
   Serial.println("AT+CIPSHUT\r\n");
  delay(2000);
  while(Serial.available()){
    char x = Serial.read();
    Serial.print(x);
  }
  delay(2000);
 
  Serial.println("AT+CIPMUX=0\r\n");
  delay(2000);
  while(Serial.available()){
    char x = Serial.read();
    Serial.print(x);
  }
  delay(2000);
 
  Serial.println("AT+CIPSTATUS\r\n");
  delay(2000);
  while(Serial.available()){
    char x = Serial.read();
    Serial.print(x);
  }
  delay(2000);
 
  Serial.println("AT+CGDCONT=1,\"66.226.75.158\",\r\n");
  delay(2000);
  while(Serial.available()){
    char x = Serial.read();
    Serial.print(x);
  }
  delay(2000);
 
  Serial.println("AT+CGACT=1,1\r\n");
  delay(2000);
  while(Serial.available()){
    char x = Serial.read();
    Serial.print(x);
  }
  delay(2000);
 
  Serial.println("AT+CIPSTATUS\r\n");
  delay(2000);
  while(Serial.available()){
    char x = Serial.read();
    Serial.print(x);
  }
  delay(2000);
 
  Serial.println("AT+CIICR\r\n");
  delay(2000);
  while(Serial.available()){
    char x = Serial.read();
    Serial.print(x);
  }
  delay(2000);
 
  Serial.println("AT+CIFSR\r\n");
  delay(2000);
  while(Serial.available()){
    char x = Serial.read();
    Serial.print(x);
  }
  delay(2000);
 
   Serial.println("AT+CIPSTART=\"TCP\",\"66.226.75.158\",\"30175\"\r\n");
  delay(2000);
  while(Serial.available()){
    char x = Serial.read();
    Serial.print(x);
  }
  delay(2000);
 
  Serial.println("AT+CIPSEND=91\r\n");
  delay(2000);
  while(Serial.available()){
    char x = Serial.read();
    Serial.print(x);
  }
  delay(2000);
 
  Serial.println("$FRCMD,1234,_SendMessage,,0120.40000,N,10314.40000,E,12.0,21.60,10.0,020715,031157.000,1*67"); // message that I want to send
  delay(2000);
 
  Serial.println();
  delay(2000);
  while(Serial.available()){
    char x = Serial.read();
    Serial.print(x);
  }
  delay(2000);
  // put your main code here, to run repeatedly:

}


Can anyone help me with the coding for using TCP protocol to send data to the server? I would really appreciate it.
Thank you.

Regards,
Nicky
2015-07-10 09:55:01 OK.

Btw , thank you so much.

Regards,
Nick
userHeadPic 13053167
2015-07-09 12:15:03 Hello,

there's page about reference page - GSM-IoT using uno and their GSM module.http://ubidots.com/docs/devices/GSMTelefonica.html?highlight=gsm

I have little experience of IoT, so I could not help now. But I am going to do it recently :)
userHeadPic Leff
2015-07-08 16:29:10 Hi leff,

I didn't try that because currently I only have GPS/GPRS/GSM SHIELD V3.0 on my hand. I got no other shields and I hope I can achieve TCP protocol using this shield. Hope you can help.

Thanks for your reply.

Regards,
Nick
userHeadPic 13053167
2015-07-03 16:21:24 HI

have you tried some other similar method like wifi shield to send data to the server?
userHeadPic Leff