Skip to content

mspalex/iot-arduino-weather-station

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IoT-arduino-weather-station

This application connects an Arduino that reads data from sensors* (temperature and humidity in this case) to a PHP application that stores the information on a Database and displays it with a Javascript library specific for Data Visualization.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisities

  • Arduino with ehternet shield or other network interface
  • Apache Web Server
  • MySQL Database Server

The web application can run within a local area network, with the help of XAMP application stack (on linux) or WAMP (on windows), but the server needs to be configured to accept local IP's. Or, like i did, on a server located outside your home network.

To know how to wire the arduino with the sensor, please refer to the guide i have hosted on instructables www.instructables.com/id/PART-1-Send-Arduino-data-to-the-Web-PHP-MySQL-D3js

1. Database preparation

First, create a database named anything you like and then run the following sql script:

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

Then create an SQL user with password and attribute previleges for the newly created database.

You will need to replace the credentials in the file includes/connect.php with the new ones.

	function Connection(){

		$server="server";
		$user="user";
		$pass="pass";
		$db="XXX";
		
		...
	}

2. PHP Web Application

Next, copy the php app files to a server location, taking into account the following:

3. Arduino Web Client

To configure the server ther arduino connects to, in the file Arduino_client.ino, lines 42 and 44 will take the address of your own server. This address can either be a normal webdomain or an IP Address.

	void loop(){
	
		...

		if (client.connect("www.*****.*************.com",80)) { // REPLACE WITH YOUR SERVER ADDRESS
			... 
			client.println("Host: *****.*************.com"); // SERVER ADDRESS HERE TOO
			... 
		} 

		...
	}

Next, you can upload the code to your Arduino and connect it to the network. This Arduino code is designed to use Dynamic IP Addresses, so that it can be used on normal home networks without IPS conflicts.


Data Visualization with D3.js

This javascript library integration will render the information like in the following image.

D3_data_viz_double_axis

Updates to this application

First release is the code shared on Instructables, with the fully functional Arduino Client and a basic PHP Web App. The app only shows a table with the raw sql data.

The second release is the full Application using the D3.js Javascript framework to show an awesome Data Visualization of the information gathered.

About

Arduino Web client reading data from sensors (temperature and humidity) and sending to a PHP Web app to store and display the information

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages