This project grew from a personal interest in following weather conditions. I like to run, but I prefer to do so when the weather is about 60-80 degrees with moderate humidity. I thought that a weather sensor could be interesting so that I could check the weather conditions on a Raspberry Pi (or a mobile device) to determine if my run would be comfortable. Since I have an interest in “steampunk,” I envisioned this weather server as a utility that an captain would need on his airship to determine his latitude, longitude, the current temp and humidity, as well as whether the sails would be billowing.

The project is hosted on a raspberry pi that was set up as a web server running the Apache open source web server application. I registered as a developer with http://www.openweathermap.org to receive a developer key for the Open Weather Map API. I wrote PHP code surrounded by HTML5 cascading style sheet to port in the Open Weather Map data for the parameters that I wanted to display in a web interface of weather data for the specified location.

Step 1: Gather Necessary Materials



  • PHP web language
  • HTML5 web language

Step 2: Configure the Raspberry Pi

Install Rasbian software on the Raspberry Pi. I strongly suggest setting a password for the device.

Once the Raspberry Pi has been loaded with software, update the software. At the prompt, type:

sudo apt-get update.

Install the apache web server. At the prompt type:

sudo apt-get install apache2 –y

Check the configuration in the browser. Go to http://localhost. A page should display showing Apache.

Open the terminal program on the Raspberry Pi. Change to the html directory which hosts the web server files and list files. At the prompt, type:

Cd /var/www/html.

Ls –al

Install PHP module for Apache web server. At the prompt, type:

Sudo apt-get install php5 libapache2-mod-php5 –y

Remove the index.html file. At the prompt, type:

Sudo rm index.html

Create the index.php file. At the prompt, type:

Sudo leafpad index.php

Step 3: Prepare the PHP Code to Draw Weather Data for Your Location.

Register with openweathermap.org to obtain a free developer key: http://openweathermap.org/api. A free key allows use of current weather data. A lists of available data parameters are located at http://openweathermap.org/api.

Look up the specific location ID in “Weather in your city.” The resulting URL will show the ID for the location.

Update the code for your location's URL.

Add a CSS file and HTML5 code to the /var/www/html folder. The HTML5 code should link to the stylesheet to format a “wrapper” around the PHP code.

Save the index.php file in the /var/www/html folder.

The specific code that I used is attached. Feel free to modify them and use them.

Step 4: Viewing Your Weather Portal Data

On the Raspberry Pi web server, the final product can be viewed in the web browser by navigating to: http://localhost. This only works on the Raspberry Pi itself since it’s displaying what is in its own html folder.

On mobile devices on the same network, the weather page can be viewed by navigating to the IP address of the raspberry pi. To find the IP address, open a terminal and type: ifconfig. The local address will be listed under the lan0 network adapter.

<p>Thanks for sharing :)</p>

About This Instructable




More by cucmq:UV Sensor Displayed on LCD Screen Using Arduino Raspberry Pi Web Server Weather Interface 
Add instructable to: