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.
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);
?>
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??
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.
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.
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?