Sim900 gprs send data webpage?

Hello I'm trying to send the data a 1 or 0 from the example sketch i found online at https://www.cooking-hacks.com/documentation/tutorials/gprs-gsm-quadband-module-arduino-raspberry-pi-tutorial-sim-900#step8

Sketch in text file attached below.

I figure out how to setup the apn information from my phone provider but the problem I'm having is sense i do not know php or mysql i do not know how to make a page to send the data from the gsm shield to the webpage and store the information in the mysql if someone has done this all ready can you please help me out i know nothing about php or mysql. Thank you.

gsmgprs.txt (5.92 KB)

Can someone please help me i do know know how to create php sites or mysql in order to display the information from the gsm shield.

i know nothing about php or mysql

Then why are you trying to use them? PHP is based, roughly, on C, and there is (relatively) good documentation, and examples, for almost everything, including executing SQL statements after connecting to a database.

Let us assume that we have a database called DatabaseName, and in that database we have a single table called TemperatureTable which has one field, a float called Temp.

First we need to send data to the database by GPRS. We will pass the data using GET, which is simply appending variable name and value to the url, and we will pass it to a php script called InsertTemp.php

(set up a SoftwareSerial instance called mySerial)

char URL[200]="AT+HTTPPARA=\"URL\",\"http://www.mywebsite.com/cgi-bin/InsertTemp.php?Temp="

(add the temperature reading to this character array - dtostrf?)
.
.
.

  mySerial.println("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");//setting the SAPBR, the connection type is using gprs
  delay(1000);
 
  mySerial.println("AT+SAPBR=3,1,\"APN\",\"CMNET\"");//setting the APN, the second need you fill in your local apn server
  delay(4000);
 
  mySerial.println("AT+SAPBR=1,1");//setting the SAPBR, for detail you can refer to the AT command mamual
  delay(2000);
 
  mySerial.println("AT+HTTPINIT"); //init the HTTP request
 
  delay(2000); 
  mySerial.println(URL);// setting the httppara
  delay(1000);
 
  mySerial.println("AT+HTTPACTION=0");//submit the request 
  delay(10000);//the delay is very important, the delay time is base on the return from the website, if the return datas are very large, the time required longer.
 
  mySerial.println("AT+HTTPREAD");// read the data from the website you access
  delay(300);
 
  mySerial.println("");
  delay(100);

And the php code (InsertTemp.php) to write the data to the database:

<?php
// Create connection
$username = "username";
$password = "password";
$hostname = "localhost"; 
$dbhandle = mysql_connect($hostname, $username, $password) 
or die("Unable to connect to MySQL");

$selected = mysql_select_db("DatabaseName",$dbhandle) 
or die("Could not select database");

$result = mysql_query("INSERT INTO TemperatureTable (Temp) VALUES ('" . $_GET[Temp] . ")",$dbhandle);

echo "<html>";
echo "<head><Title>Done</title>";
echo "</head>";
echo "<body>";
echo "</body>";
echo "</html>";
mysql_close($dbhandle);
?>

To test that the php script works submit a value manually by a web browser:
http://www.mywebsite.com/cgi-bin/InsertTemp.php?Temp=12.34

Hello Paul i didn't know php was part of the C language something new to me.

Hey Dannable what is the database name and table name? i don't see it? oh is it $selected = mysql_select_db("DatabaseName",$dbhandle) "DatabaseName" that is where i have to put the database name? I'm trying to create a database asking for a table name and then when creating that ask for a Field name.

Okay i think i got it my database name is sim900testdata the table name is TemperatureTable and the field name is Temp. so that is set but when i go to my site http://www.mysite.com/test/InsertTemp.php?Temp=12.34 and put that in manually it says Done. but when go to the mysql page to view it says Empty nothing there??

The URL needs to be the path to your php script, not the database. Convention says that you put them in the cgi-bin directory.

Yes, DatabaseName is where you put your database name...

I have a shared account on godaddy i don't see a cgi bin folder or anything like it there?

Is there a way to do it without putting it into a Cgi bin?

You'll have to read their documentation or contact the help desk for support - I'm not familiar with them.

As long as you specify the path to the script I imagine it will be fine.

It's returning the html you specified so it can find the script. Which suggests that there is a problem writing to the database.

In the line echo "<head><Title>Done</title>"; change the word 'Done' to something distinctive so you know it's yours!

And you might want to remove the url to stop other people posting spurious data?

I'ts just a temporary link it won't be there tomorrow just for test today but you are right thank you.

Hello Dannable I now manually can add in the field but when i go to upload the sketch and i open a serial monitor it says

Starting...
AT
AT
AT
AT
AT
AT
AT
AT
AT

and keeps going thats all i losted my sketch into a text file to big for here attached below.

gsmsketch2.txt (7.22 KB)

Hello dannable i still can't get it to transmit from the arduino gsm to the webpage even though i got the correct link and correct apn there is no pin or username and password for the apn i checked with my phone provider.

What about passwords for writing to the database?

And this sounds like a php issue, which strictly speaking is outside the remit of this web site? You need to put some debug statements into your php script so you can tell which stage it is going wrong.

what do you mean password the database is working i found a tut online how to setup mysql and i put php page in there also in that tut shows you how to display the php so i putanother page http://www.codehunter.info/sim900testdata/InsertTemp.php?Temp=12345 is to insert it into the database and http://www.codehunter.info/sim900testdata/testing.php is to view it.

so that part is working but something is not right with the arduino part sending it.

So you need to debug your Arduino code to find out where the error is?

All I will do this evening is put the commands into Serial Relay and see what happens, but that will be using my provider / APN settings.

I entered the commands into serial relay:

AT+SAPBR=3,1,"CONTYPE","GPRS"

OK
AT+SAPBR=3,1,"APN","***********.co.uk"

OK
AT+SAPBR=3,1,"USER","******"

OK
AT+SAPBR=3,1,"PWD","******"

OK
AT+SAPBR=1,1

OK
AT+HTTPINIT

OK
AT+HTTPPARA="URL","http://www.**********.****/sim900testdata/InsertTemp.php?Temp=22"

OK
AT+HTTPACTION=0

OK

+HTTPACTION:0,200,58
AT+HTTPREAD

+HTTPREAD:58
<html><head><Title>Done</title></head><body></body></html>
OK

hey dannable i tried in a program i found online called uart command the same commands and it works but for some reason that sketch ant it missing some stuff in it something is wrong i can feel it. but not sure what it is. how do i put these commands in there the only thing is that my sim900 uses d7 and D8 for the rx and tx i don't see that in the sketch and i do see normal things i see normally with my other gsm sketeches so i have no clue whats really missing or why it won't work?

I'm taking one of my other Gsm sketches and changing it to put these commands in. Danno is there a stop command? or a turn off command?