Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Arduino Networking

You're reading from   Arduino Networking Connect your projects to the Web using the Arduino Ethernet library

Arrow left icon
Product type Paperback
Published in Aug 2014
Publisher
ISBN-13 9781783986866
Length 118 pages
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Marco Schwartz Marco Schwartz
Author Profile Icon Marco Schwartz
Marco Schwartz
Arrow right icon
View More author details
Toc

Log incoming data in a database

In this section, we are going to use PHP to build the server-side part of the project. If you are a complete novice in PHP, I recommend the following resource to learn the basics of the language:

http://php.net/manual/en/tutorial.php

First, we are going to see the content of the datalogger.php file. This file will handle the requests coming from the Arduino board, log the data in a database, and answer with a simple message. Note that this file has to be in a folder named datalogger on your web server. We will see the important parts of the code. To get the complete code for this section, please refer to the GitHub repository of the chapter. Note that all the PHP code should be between the <php … ?> tags.

The file starts by receiving the data from the GET request sent by the Arduino Ethernet shield:

$temperature = intval($_GET["temp"]);
$humidity = intval($_GET["hum"]);

We also instantiate the connection with the SQLite database...

You have been reading a chapter from
Arduino Networking
Published in: Aug 2014
Publisher:
ISBN-13: 9781783986866
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime