O'Reilly logo

Internet of Things Programming with JavaScript by Ruben Oliva Ramos

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Datalogger with MySQL

In the following section, we will build a Datalogger that will record the data temperature and humidity in the server so that we can get data whenever we want and display it in a web page.

Programming the script software

In the following code, we have a script that will communicate with the Arduino board, and it is installed in the server.

You can now either copy the code inside a file called datalogger1.php, or just get the complete code from the folder for this project: 

<?php if (isset($_GET["temp"]) && isset($_GET["hum"])) { $temperature = intval($_GET["temp"]); $humidity = intval($_GET["hum"]); $con=mysql_connect("localhost","root","ruben","arduinobd"); mysql_select_db('arduinobd',$con); if(mysql_query("INSERT INTO measurements ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required