Perform HTTP POST request with GSM shield

Hello everyone,

I am trying to upload the data I get from a temperature sensor to my client server. I am using a php script and I have a MYSQL database, on the server side. I want to perform an http post request in order to upload the data from the sensor to the server. I am using an arduino uno and the gsm shield. I searched for weeks on the internet about a solution to my problem but couldn't find a way to upload data with the gsm shield. Everyone says that you can perform http post requests but never seen an example. Is it possible? Can you share an example with the code? Thanks in advance.

Yes it is possible. I actually got this working for the first time today!

The logic as follows. You set up a php to 'get' data from URL parameters. This means as soon as someone types the URL with data contained in the URL into their browser this data will be pushed through to mysql. Your arduino can do the same.

The following example was taken from parts of a php tutorial. It's to store first name, surname and address in a table. The php file is called test.php located on your sever. Once you've established a database connection use the following code in the PHP file

$SQL = "INSERT INTO tbl_address_book (First_Name, Surname, Address) VALUES ('".$_GET['FN']."', '".$_GET['SUR']."', '".$_GET['Ad']."')";

$result = mysql_query($SQL);

Then if you go to your browser and type this you should see a new entry in your database. yourwebsite.com/test.php?FN=Alex&SUR=Dave&Ad=Australia

From the arduino side you just need it to connect to the site with the parameters in the URL.

The following tutorial http://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands shows how to connect to the internet using AT commands. Find an AT command sketch that works for your module and type them out in that order. Change this line AT+HTTPPARA="URL","http://marsinnovations.in/testout.php"

to this

AT+HTTPPARA="URL","http://yourwebsite.com/test.php?FN=Alex&SUR=Dave&Ad=Australia"

and end at the next line. AT+HTTPACTION=0

The arduino connects to the website and thats enough to pass the data on. You'll just have to code the arduino to replace the names(data) with a variable.