Wednesday, December 16, 2015

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.

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.

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



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

    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.

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...