2

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

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,\"/add.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,/add.php,filename

ERROR +UHTTPC=2,1,/add.php,filename

ERROR +UHTTPC=2,1,/add.php,filename

ERROR +UHTTPC=2,1,/add.php,filename

ERROR ...

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

  • The examples in the manual have quotes around the PHP file and the filename - just like you have for the FQDN entry. Maybe you should add them...? – Majenko Feb 19 '16 at 20:37
  • Thank you for your support, but my problem is in the meaning and perpose of responseFilename and how could i work with it? – Haykel BEN ABID Feb 21 '16 at 14:08
  • Your problem is that you have an error. The filename is where to store the response in the internal filesystem, and the word filename is perfectly valid - as long as you use quotes around your strings. – Majenko Feb 21 '16 at 15:10
  • even when i add the quotes it still giving me an error. please check my new modification in code. – Haykel BEN ABID Feb 21 '16 at 15:33
  • 1
    Try using AT+UHTTPER to get the error code from the request, see if that helps. – Majenko Feb 21 '16 at 16:20
1

I worked on a project similar to yours. I think you forgot to establish a connection first. Just add those lines of code at the top of setup() method:

 gprsSerial.println("AT+UPSDA=2,0"); //Reset connection
 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.