One of the reasons for having multiple PI’s was to have one take over duties from an aging ITX based Linux box of reading from a USB Weather station and uploading the data to both it’s websiteand WeatherUnderground.

Unfortunately this project got pushed forward when, last Thursday morning, the ITX box decided to die on me. I think it’s power supply finally gave out after 9 years of service.

So this is the first part of a series on setting up a USB weather station onto a Raspberry PI.

Part 1 – The Weather Station

The weather station that I’ve been using since November 2010 is one I bought from Maplin. They usually sell for about £125 but a couple of times a year they reduce them down to between £50-£70. N96FY USB Wireless Weather Forecaster. At the time of writing this they’ve got it reduced to £69.

It consists of the external sensors and an internal touch screen unit. All that’s needed is a USB A-A cable to connect the touch screen to the PI.

Configuring the Raspberry PI

First I started with a blank copy of raspian on a 4Gb SD Card. Booted the pi up and configured it to use the entire card. With raspian this is easy as you get prompted on the first boot to do it. At the same time I enabled the ssh server from that same menu.

Installing the software

Now this is based on the instructions over on who got a Raspberry PI working with one of these weather stations. Those instructions are for the Debian based image. I’ve taken them and modified them to get working with raspian so there are a few minor changes.

First we need to install some dependencies:

pi@kell ~ $ sudo apt-get install git python-dev
pi@kell ~ $ sudo apt-get install gnuplot python-simplejson python-tweepy python-paramiko

Next we need to download and compile the latest versions of a few dependencies as the versions in the repos are not up to date.

First is Cython:

pi@kell ~ $ mkdir work
pi@kell ~ $ cd work
pi$kell ~/work $ tar xzf Cython-0.16.tar.gz
pi$kell ~/work $ cd Cython-0.16
pi$kell ~/work/Cython-0.16 $ sudo python install

That will take a while…

Next is libusb:

pi$kell ~/work/Cython-0.16 $ cd ~/work
pi$kell ~/work $ tar xjf libusb-1.0.9.tar.bz2
pi$kell ~/work $ cd libusb-1.0.9
pi$kell ~/work/libusb-1.0.9 $ ./configure
pi$kell ~/work/libusb-1.0.9 $ make
pi$kell ~/work/libusb-1.0.9 $ sudo make install

Next is cython hidapi:

pi$kell ~/work/libusb-1.0.9 $ cd ~/work
pi$kell ~/work $ cd cython-hidapi
pi$kell ~/work/cython-hidapi $ vi

Now we need to change the path to libusb from /usr/include/libusb-1.0 to /usr/local/include/libusb-1.0. Make that change then save.

pi$kell ~/work/cython-hidapi $ sudo python install

Now finally pywws:

pi$kell ~/work/cython-hidapi $ cd ~/work
pi$kell ~/work $ tar xvzf pywws-12.05_r521.tar.gz
pi$kell ~/work $ cd pywws-12.05_r521
pi$kell ~/work/pywws-12.05_r521 $ sudo python

Thats the basic installation, for the rest I’d suggest reading the pywws documentation.

The one thing I’d suggest is moving the installation out of your home directory, for me thats:

pi$kell ~/work/pywws-12.05_r521 $ cd ~/work
pi$kell ~/work $ sudo mv pywws-12.05_r521 /usr/local/weather

In the next article I’ll cover configuring it to upload to Twitter, Weather Undergound, The Met Office & to a website.


In the first article I covered how to install a weather station on a Raspberry PI. In the second part I’ll cover how to get it to upload data on an hourly basis to a website using FTP.

Getting the station to run hourly

First we need to get the station to run hourly. To do this I created a script called weatherupload which I placed under /usr/local/bin

pi@kell: ~$ sudo vi /usr/local/bin/weatherupload

Enter the following:

cd /usr/local/weather
python -vvv data

Once saved make it executable and then edit the main crontab:

pi@kell: ~$ sudo chmod +x /usr/local/bin/weatherupload
pi@kell: ~$ sudo vi /etc/crontab

At the end of the file you need to add the following:

0 * * * * root /usr/local/bin/weatherupload

Save it and now every hour it will now run.

Note: I’ve placed it there and not under /etc/cron.hourly because

  1. cron.hourly runs once an hour, but not necessarily at the top of the hour. I a later article when I add twitter you want the tweet to be close to 0m rather than at a random time.
  2. I’ve found in the past that using crontab -e doesn’t always work, even for root but in the core crontab it just works

Uploading to a website

First to generate the graphs pywws uses gnuplot so we need to install it:

pi@kell: ~/sudo apt-get install gnuplot

Next we need to add some details to the stations weather.ini file. At the top theres a section called paths. Make sure those point to the relevant templates and graph_templates directories in your pywws install.
Next under the hourly section you should see a pair of lines:

plot = []
text = []

You need to add the plots and pages that need to be generated:

plot = ['7days.png.xml', '24hrs.png.xml', 'rose_24hrs.png.xml', 'rose_7days_nights.png.xml']
text = ['current.html', '24hrs.html', '6hrs.html', '7days.html', 'feed_hourly.xml', 'allmonths.html']

Finally theres the ftp section which needs configuring with the remote ftp server (your web host will give you these):

secure = False
site =
local site = False
user =
directory = /weather/
password = mypassword

That’s about it. Now when you run the hourly script it will generate some simple pages & images to your website.

You can see an example of this over at – although the uploaded templates only form part of that site.

Following a number of requests I have created below the steps required to connect a Maplin USB Weather Station to a Raspberry Pi using the pywws python software.

What you need

  • A wireless ethernet connection with a powered USB hub


I found that a powered hub is not required with a direct ethernet cable to your router, keeping the power usage to a minimum, but you will probably require one when using a wireless dongle. Plus I had some issues with the wireless connection dropping out, and so reverted back to wired.

The weather sensors communicates to the weather station using radio frequencies, then via USB to the Raspberry Pi. The Raspberry runs a python program called pywws written and maintained by Jim Easterbrook found here. The instructions below explain the changes required in order to run on the Raspberry Pi.

Step 1 – Initial Setup

Create an SD card (at least 4GB) with the Raspbian “wheezy” image at

I use a Medion 8Gb Class 4 purchased from Aldi. There will be plenty of space on this for many years of data.
Boot the Raspberry Pi with the SD card User pi Password raspberry.

Resize the partition to the full capacity of the card using the raspi-config menu. If it does not start automatically or you are using ssh, type sudo raspi-config at the command prompt.

Change the password to something other than the default.

Set the time zone correctly as an incorrect time will cause problems with synchronising to the weather station later.

As we won’t be using much GPU, set the memory split and change the value to 16.

I usually set ssh to enable so that I can control the Pi from another machine and therefore won’t require a monitor on the Pi in future.

Finally exit the menu and update the Pi using the commands:

  • sudo apt-get update
  • sudo apt-get upgrade

Reboot by typing

  • sudo reboot

Step 2 – Installing the software

Install pip and python-dev

  • sudo apt-get install python-pip
  • sudo apt-get install python-dev

Create a directory for the application builds:

  • cd ~
  • mkdir dls
  • cd dls

Download the libraries and applications required:

    • wget
  • wget
  • git clone

Expand the files into their directories and files:

  • tar xvzf Cython-0.16.tar.gz
  • tar xvjf libusb-1.0.9.tar.bz2

Compile and install Cython 0.16 (This can take some time):

  • cd ~/dls/Cython-0.16
  • sudo python install

Install libusb-1.0.9

  • cd ~/dls/libusb-1.0.9
  • ./configure
  • make
  • sudo make install
  • cd ~/dls/cython-hidapi

Step 3 – Install cython-hidapi

  • cd ~/dls/cython-hidapi

Replace the file

  • wget -O

Copy the file and install

  • sudo cp /lib/arm-linux-gnueabihf/ /usr/lib/arm-linux-gnueabihf/
  • sudo python install

Step 4 – Install pywws

Install the latest version of pywws to the weather directory

  • cd ~
  • sudo pip install pywws

Step 5 – Testing

Connect the weather station to the Pi with the USB connection.

Test the weatherstation

  • sudo python -m pywws.TestWeatherStation

You should see a series of Hex numbers if the connection is working.

Next – Setting up pywws