INGREDIENTS:
- 1x Linkit ONE board
- 1x GPS antenna
- 1x Lithium-ion Battery
- 1x SIM
PURPOSE:
This is an evolution of this previous project. The difference is that the data will be saved on a server.
SOFTWARE:
The main difference from the previous code is the Internet connection.
After controlling if there are enough visible satellites, the code attempts to connect to your server.
if (getData(&info) > 3) { if (client.connect(server, port)) {
If the connection is established, it makes a request to a file named "store_data. php" located on your server, and sends the data to be stored.
String str = "GET /store_data.php?"; str += "date="; str += date_format; str += "&time="; str += time_format; str += "&lat="; str += lat_format; str += "&lon="; str += lon_format; client.print(str); client.println(" HTTP/1.1"); client.print("Host: "); client.println(server); client.println("Connection: close"); client.println();
In this project I send only date, time, latitude and longitude, but you can add all the data you want by adding them to str, in the following format:
str += "&";
str += data_name;
str += data_value;
In store_data.php, change the following line according to the data you send from Linkit ONE
$param_names = array("date", "time","lat","lon");
The php page will create a file on the server, containing the data you sent from Linkit
for($i=0; $i< count($param_names); $i++) { $line = $line.getParameter($param_names[$i]); if($i<count($param_names)-1)$line = $line.","; } $line = $line."\n"; file_put_contents($file, $line, FILE_APPEND | LOCK_EX);
Comments