Haykel BEN ABID
Haykel BEN ABID

Reputation: 13

Sending data to a webserver with GPRS/GPS Shield (U-blox Sara G-350)

I am working on a project for tracking cars. I am using an Arduino UNO to receive the position from GPS/GPRS shield. I am OK on obtaining the coordinates position. Now I need to send the position to a webserver and then show it on a webpage using the Google Maps API. Which accepts it in a POST or GET method. Here is the shield model: U-blox Sara G-350 and this is its manual here

Domain:"www.navtec.16mb.com" (well hosted) Path:"/test/getter.php" (tested and worked perfectly with browser GET / POST) Apn:weborange (OK)

Here is my approach:

#include <SoftwareSerial.h>
#include <String.h>


SoftwareSerial gprsSerial(7 ,8);

void setup() {
  // put your setup code here, to run once:
  gprsSerial.begin(19200);                
  Serial.begin(19200);     
  delay(2000);

 gprsSerial.println("AT+CGDCONT=3,\"IP\",\"weborange\"");
 toSerial();
 delay(2000);

 gprsSerial.println("AT+UHTTP=0");
 toSerial();
 delay(2000);
 gprsSerial.println("AT+UHTTP=2,1,\"www.navtec.16mb.com\"");
                   //AT+UHTTP=<profile_id>,<op_code>,<HTTP_server_name>
 toSerial();
 delay(2000);

 gprsSerial.println("AT+UHTTP=0,5,80");
 toSerial();
 delay(2000);

}

void loop() {

 //gprsSerial.println("AT+UHTTP=2,1,\"submit\"");
                    //AT+UHTTP=<profile_id>,<op_code>,<param_val>[,<param_val1>]
 //toSerial();
 //delay(2000);

 gprsSerial.println("AT+UHTTPC=2,1,/test/getter.php,filename");  //Problem here!!!!!!!!
                   //AT+UHTTPC=<profile_id>,<http_command>,<path>,<filename>[,<param1>[,<param2>[,<param3>]]]
 toSerial();
 delay(2000);
}

void toSerial()
{
  while(gprsSerial.available()!=0)
  {
    Serial.write(gprsSerial.read());
  }

}

This is what I get:

+CGDCONT=3,"IP","weborange"

OK +UHTTP=0

OK +UHTTP=2,1,"www.navtec.16mb.com"

OK +UHTTP=0,5,80

OK +UHTTPC=2,1,/test/getter.php,filename

ERROR +UHTTPC=2,1,/test/getter.php,filename

ERROR +UHTTPC=2,1,/test/getter.php,filename

ERROR +UHTTPC=2,1,/test/getter.php,filename

ERROR ...

Thanks for your time, I am waiting for your support, any ideas could help. Sorry for my bad English

Upvotes: 1

Views: 984

Answers (1)

Malek Boubakri
Malek Boubakri

Reputation: 856

I worked on a project similar to yours, i think you miss to establich a connexion first. Just add those line of code in the tor of setup() method:

 gprsSerial.println("AT+UPSDA=2,0"); //Reset connexion
 toSerial();
 delay(2000);
  gprsSerial.println("AT+UPSD=2,1,\"weborange\""); //Establish a new one
 toSerial();
 delay(2000);
 gprsSerial.println("AT+UPSDA=2,3"); 
 toSerial();
 delay(2000);
 gprsSerial.println("AT+UPSND=2,0");
 toSerial();
 delay(2000);

I hope it works for you. else, you can use AT+UHTTPER=2 after all to check for error source.

Upvotes: 1

Related Questions