4. Setting Up the Pi Weather Station

1. Make sure you’re ready to start this section

You should have already put together the components of the weather station and started it up. If you have not put it together, follow the instructions here. If you have not started it up, don’t know how to, or could just use a few helpful hints, go here.

Want to know more about the commands being run here? Hover over each word in the code boxes to see a short description of what it is.

2. Set up your Pi so that it can communicate with the sensor:

The way to do this is double click on the LXTerminal icon to open a command window if you haven’t already and run the following code. Remember to run the code you need to write it and then press enter:

sudo nano /etc/modules

modules

Then add these two lines to the end of the file that opens (remembering that you can only use keyboard arrows to move about the page)

i2c-bcm2708
i2c-dev

Exit this file by pressing the control key and X together, then press Y to continue and then enter to save the file.

3. Reboot the Pi

Use the command sudo reboot and then go back to the LXTerminal program as you did at the start by putting your username and password in and then running the code startx, before clicking on LXTerminal.

4. Run these commands

Don’t forget to press “Y” if the program asks for permission to continue:

sudo apt-get install python-smbus
sudo apt-get install i2c-tools

Your window should look something like this (if it doesn’t look exactly like this then don’t worry, as long as there are no errors then it has installed)

installi2c

5. Edit the blacklist file

Depending on your Pi’s setup you may now need to edit another file. If your Pi does not have this file then you can skip this step. To find out if your Pi has this file run the command – if the LXTerminal changes to a black empty screen press control and x to cancel, as you do not have the file. If a file with text in appears you will need to edit it.

sudo nano /etc/modprobe.d/raspi-blacklist.conf

Put a hashtag (#) in front of:

blacklist spi-bcm2708
blacklist i2c-bcm2708

This will look like this on your screen:

blacklist

Now press control and X to exit, pressing Y and enter to save the file.

6. Check if this all has installed correctly

To check if this has worked, run this code:

sudo i2cdetect -y 0 (if you are using a version 1 Raspberry Pi)
sudo i2cdetect -y 1 (if you are using a version 2 Raspberry Pi)

This is both codes run on a Version 2 Pi – as you can see, the code for Version 1 just returns blanks

If you are not sure which version your Pi is, you can run both commands, as shown in the picture above. The Pi used here is a version 2, so running the code for the version 1 just returns blank spaces. If your sensor is connected correctly and you have installed everything before correctly, then you should see a “77” in the bottom row of the output. If you don’t see this, then check if you have followed the instructions correctly to install i2cdetect or visit the Errors and Troubleshooting page. Don’t worry if you see (or don’t see) numbers other than the 77 elsewhere in the output (like the 04 and UU shown). These are other connected devices, which you don’t need to worry about.

7. Get the Adafruit library onto your Pi.

This interacts with the sensor and is very important in the code you’ll eventually run.

sudo apt-get update
sudo apt-get install git build-essential python-dev

installallofthis

git clone https://github.com/adafruit/Adafruit_Python_BMP.git

gitcloneada

cd Adafruit_Python_BMP
sudo python setup.py install

installpysetup

Was that installed? Check it by running this code! (Your command line should still start with “~/Adafruit_Python_BMP $“. If it is there then run the two commands below. If it is not then rerun the command cd Adafruit_Python_BMP)

cd examples
sudo python simpletest.py

simpletest

8. Now go out of the Adafruit directory

You can get rid of the ~/Adafruit_Python_BMP/examples script at the beginning of the line by typing cd, as shown at the bottom of this picture:

cdexample

9. Install the graphing software.

Run this code to install the support for the Plot.ly streaming software:

sudo apt-get install python-pip
sudo pip install plotly

10. Download Weather Station file or follow link to write the code yourself

Almost there! Now download the Sheffield Pi Weather Station code file using this code or (if you want a bit more of a challenge), you can write the code for it yourself with the instructions on the Coding the Weather Station from Scratch page.

git clone https://github.com/SheffieldPi/Sheffield-Pi-Weather-Station.git

gitclonepi11. Run Weather Station software

Now you have all you need to run your weather station, and all that is left is to run it! The software download will have put the file we need into a folder, so in the LXTerminal we’re going to call up that folder so we can make our software run.

cd /home/pi/Sheffield-Pi-Weather-Station

navigatetoPiNow everything is set up to work. Just run this line of code and follow the prompts for login data that will come up on your screen to start uploading your data. Your data will also be saved in a file in the /home/pi/Sheffield-Pi-Weather-Station folder

sudo python Thermo_Station.py

13. Find your data on the websites it has uploaded to, or get the data file.

If that all works, then you can check out your data by going to the Weather Observations Website and finding your weather station’s location, or go to Plot.ly and look at your graph there! The weather data will also have been saved to a file called “data.txt” which will have appeared in the /home/pi/Sheffield-Pi-Weather-Station folder. The two pictures below are examples of what your WOW site and Plot.ly graph will look like.

metwow

This is the Met Office Weather Observation Site with the uploaded data

This is what your Plot.ly graph should look a little like.

This is what your Plot.ly graph should look a little like.

12. Using your weather station.

To use your weather station, you could set it up near a window or outside, as long as it is not in direct sunlight. To avoid rain or damp getting to the electronics, you can use a plastic food container to put the sensor in, and then run the wires inside to your Pi – the only limit here is the length of wire you have! This is shown in the photo below.

A standard food container can be used to protect the data sensor

A standard food container can be used to protect the data sensor

Want to do more with your weather station? Visit here to set up your Pi to run the weather station automatically at start-up without having to enter commands. Want to make the software from scratch and add in whatever extra functions you want? Visit here!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s