AntarcticPilot
Well-Known Member
I use MySQL and a web server.
My Arduino has a TCP/IP stack available due to the GSM card. This has embedded HTTP commands. Therefore the arduino simply makes a http call to my webserver with the values as parameters. Note: some details have been changed to protect my system.
So the Arduino makes this web call to the server...
Code:http://www.yourwebsite.com/yourscript.php?value0="15"&value1="54"&value2="13"&value3="13"&value4="1"
This is the code in the arduino
Code:String webstring = "AT+HTTPPARA=\"URL\",\"http://"; webstring.concat("YOUR_URL"); webstring.concat("/yourscript.php?value0="); webstring.concat(t); webstring.concat("&value1="); webstring.concat(h); webstring.concat("&value2="); webstring.concat(batt1); webstring.concat("&value3="); webstring.concat(batt2); webstring.concat("&value4="); webstring.concat("1"); webstring.concat("\"\r\n"); sprintf(webbuffer, "%s", webstring.c_str()); printLCD(ALERT_ROW, F("HTTP GET Param"));
On the webserver I then have a php script as follows
Code:<?php $value0=$_GET['value0']; $value1=$_GET['value1']; $value2=$_GET['value2']; $value3=$_GET['value3']; $value4=$_GET['value4']; $opendb=mysql_connect("localhost","USERNAME","PASSWORD") or mysql_error("ERROR"); mysql_select_db("DATABASE",$opendb); if ($opendb){ $query = "INSERT INTO DATABASE VALUES( '', '$value0', '$value1', '$value2', '$value3', '$value4', UNIX_TIMESTAMP());"; /* Run the query */ $result= MYSQL_QUERY($query) or die( "ERROR" ); mysql_close($opendb); echo "DBOK"; } else { echo "ERROR";
Once its into a database on a webserver then the "world is your lobster"![]()
- you can present and manipulate the data in a multitude of ways.
You can run a small server on a Raspberry Pi
A quick look at your server code suggests that it would be vulnerable to a SQL insertion attack. Creating SQL strings by concatenation is dangerous (see https://xkcd.com/327/ for an amusing take on this!).
Of course, if this is entirely on a firewalled internal network, then it probably isn't a real concern, but it is bad practice.
