Wednesday, December 16, 2015
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. 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:
$query = "INSERT INTO `tempLog` (`temperature`, `humidity`)
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.
Posted by Steve Spence at 10:09 AM