PART 1 – Send Arduino data to the Web ( PHP/ MySQL/ D3.js )

details

This project is an example of Ethernet shield.
User can monitor a device easily by using Arduino platform through Web.
This project would be included in Sensing & Gathering category of WIZnet Museum.

PART 1 – Send Arduino data to the Web ( PHP/ MySQL/ D3.js )
2015-08-11_sensor

HARDWARE
1.Arduino Uno
2.Ethernet Shield (eBay clone)
3.DHT 11 sensor
4.breadboard
5.10k Ohm resistor
6.USB cable
7.Ethernet cable
8.wires
9.piece of acrylic
10.PCB spacers

Software
– You need access to a web server ( can be from a free hosting company ) with capability to run PHP applications and also to create databases. ( possibly cPanel with phpMyAdmin)

 

Arduino Web Client + DHT11 Sensor

Picture of Arduino Web Client + DHT11 Sensor
Picture of Arduino Web Client + DHT11 Sensor
Picture of Arduino Web Client + DHT11 Sensor
Picture of Arduino Web Client + DHT11 Sensor
Picture of Arduino Web Client + DHT11 Sensor
Picture of Arduino Web Client + DHT11 Sensor

The code is very simple, all the important section are commented. If you have any doubt feel free to ask.

Code: https://www.instructables.com/id/PART-1-Send-Arduino-data-to-the-Web-PHP-MySQL-D3js/

 

 PHP / MySQL Application

Picture of PHP / MySQL Application

In this second part i will explain briefly the PHP application and the database. The database is used obviously to store the sensor readings, so that they can be accessed later. It’s a very simple DB, with just one table with 3 columns. It stores the time stamp and the corresponding temperature and humidity values.

	CREATE TABLE tempLog (
		timeStamp TIMESTAMP NOT NULL PRIMARY KEY,
		temperature int(11) NOT NULL,
		humidity int(11) NOT NULL,
	);

The PHP application consists of 3 files:

– connect.php: this file is loaded every time we need to access to the database. It’s loaded in the beginning of the almost each file. It contains a function that returns a new connection to be used by the PHP to execute query’s to the DB. You need to store the DB configs (hostname, database, user, password) in this file.

– add.php: when the Arduino sends POST requests to the server, is to to this page. The PHP receives the values sent in the request and executes an insertion query with those values.

Sometimes you need to change the permissions of this file (should be 644), because it might be protected to allow only executions from the localhost.

– index.php: this is the website landing page. It displays the values that are stored in the database. Right now, it will display all the values in a single HTML table, just to show that works.

So, this concludes the first part of this Instructable. Feel free to ask questions about anything related, i’m glad to help.

If you want to know more in detail, refer to

Source : http://www.instructables.com/id/PART-1-Send-Arduino-data-to-the-Web-PHP-MySQL-D3js/

This project is an example of Ethernet shield.
User can monitor a device easily by using Arduino platform through Web.
This project would be included in Sensing & Gathering category of WIZnet Museum.

PART 1 – Send Arduino data to the Web ( PHP/ MySQL/ D3.js )
2015-08-11_sensor

HARDWARE
1.Arduino Uno
2.Ethernet Shield (eBay clone)
3.DHT 11 sensor
4.breadboard
5.10k Ohm resistor
6.USB cable
7.Ethernet cable
8.wires
9.piece of acrylic
10.PCB spacers

Software
– You need access to a web server ( can be from a free hosting company ) with capability to run PHP applications and also to create databases. ( possibly cPanel with phpMyAdmin)

 

Arduino Web Client + DHT11 Sensor

Picture of Arduino Web Client + DHT11 Sensor
Picture of Arduino Web Client + DHT11 Sensor
Picture of Arduino Web Client + DHT11 Sensor
Picture of Arduino Web Client + DHT11 Sensor
Picture of Arduino Web Client + DHT11 Sensor
Picture of Arduino Web Client + DHT11 Sensor

The code is very simple, all the important section are commented. If you have any doubt feel free to ask.

Code: https://www.instructables.com/id/PART-1-Send-Arduino-data-to-the-Web-PHP-MySQL-D3js/

 

 PHP / MySQL Application

Picture of PHP / MySQL Application

In this second part i will explain briefly the PHP application and the database. The database is used obviously to store the sensor readings, so that they can be accessed later. It’s a very simple DB, with just one table with 3 columns. It stores the time stamp and the corresponding temperature and humidity values.

	CREATE TABLE tempLog (
		timeStamp TIMESTAMP NOT NULL PRIMARY KEY,
		temperature int(11) NOT NULL,
		humidity int(11) NOT NULL,
	);

The PHP application consists of 3 files:

– connect.php: this file is loaded every time we need to access to the database. It’s loaded in the beginning of the almost each file. It contains a function that returns a new connection to be used by the PHP to execute query’s to the DB. You need to store the DB configs (hostname, database, user, password) in this file.

– add.php: when the Arduino sends POST requests to the server, is to to this page. The PHP receives the values sent in the request and executes an insertion query with those values.

Sometimes you need to change the permissions of this file (should be 644), because it might be protected to allow only executions from the localhost.

– index.php: this is the website landing page. It displays the values that are stored in the database. Right now, it will display all the values in a single HTML table, just to show that works.

So, this concludes the first part of this Instructable. Feel free to ask questions about anything related, i’m glad to help.

If you want to know more in detail, refer to

Source : http://www.instructables.com/id/PART-1-Send-Arduino-data-to-the-Web-PHP-MySQL-D3js/

COMMENTS

Please Login to comment
  Subscribe  
Notify of