Subscribe to Arduino Academy and start learning today for FREE!

Building a IoT Server

The “Internet of Things” is one of the most exciting topics around these days. Millions of internet enabled gadgets sending data to a data storage & reporting server, and retrieving data back for local control or display.

Our last post described sending sensor data to a server. Today we will discuss more about setting up that server. We are using a hosting service (Hostgator) which gives easy control panel access to html directories, email accounts, and MySQL databases.

Become the Maker you were born to be. Try Arduino Academy for FREE!

If you have the time and inclination, you could easily set up a local pc with windows or linux and host your own web server with php and MySQL. You would need to open up a connection through your router so that it would be publicly accessible if you need that functionality. The Raspberry Pi makes a very inexpensive IoT server. http://www.instructables.com/id/Raspberry-Pi-Web-Server/

The arduino sketch in the last post sends data to a php page called app.php which looks like the following:

include(“connect.php”);

$link=Connection();

$temp1=$_POST[“temp1”];
$hum1=$_POST[“hum1”];

$query = “INSERT INTO `tempLog` (`temperature`, `humidity`)
VALUES (‘”.$temp1.”‘,'”.$hum1.”‘)”;

mysql_query($query,$link);
mysql_close($link);

header(“Location: index.php”);

This page connects to the database (using connect.php) and inserts the temp1 and hum1 data values. The database auto fills a field called timeStamp with the server time and date.

We provide another file called index.php that displays the data in the database. We also include a sql file that creates the table for you after you have created a database (referenced in the connect.php file). Download the zip file with all the files needed to re-create this project on the previous post, and see the project in action by viewing our actual data.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

Archives

0
Would love your thoughts, please comment.x
()
x