Hardware Reference
In-Depth Information
Data received
disconnecting.
If you are seeing these messages, congratulations! It means that your Arduino Ethernet
shield is successfully communicating with the web server running on your computer, and
is actually logging some data.
If this is not the case, first check your hardware connections. Make sure the DHT11
sensor is correctly wired with the Arduino board, and that the Ethernet cable is plugged
into the shield and your Internet router. Don't hesitate to redo Chapter 1 , Discover the Ar-
duino Ethernet Shield , to make sure that your Ethernet shield is working properly.
Also, make sure that the web server is active on your computer, and that all the files of the
project (especially the datalogger.php file) are located in a folder named data-
logger inside your web server folder. You can test this independently from the Arduino
Ethernet shield. Simply go to your favorite web browser, and type:
localhost/folder_of_the_project/
datalogger.php?temp=20&hum=40
This will log some fake data inside the database, so you can be sure that the web server is
running correctly.
We are now going to check on the server side whether the data was recorded correctly.
And we are actually going to kill two birds with one stone, since this code will also be
used in the next section to plot the data.
To check that the data was recorded correctly, you can simply create a file named
readout.php , which will read data from the database, format it, and print the format-
ted data so you that can see it. First, we need to access the SQLite database:
$db = new SQLite3('database.db');
We then need to make a query to the database so it returns the data we want. In this re-
quest, we are simply going to take all the fields from the table called measurements. This
is done using the following piece of code:
$results = $db->query('SELECT id, timestamp, temperature,
humidity FROM measurements');
Search WWH ::




Custom Search