New - Connecting the Pi to a weather station

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 Raspberry Pi with power supply
  • Maplin USB Weather Station
  • An Ethernet connection
  • or
  • A wireless ethernet connection with a powered USB hub

Notes

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 http://www.raspberrypi.org/downloads.

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 http://pypi.python.org/packages/source/C/Cython/Cython-0.16.tar.gz
  • wget http://sourceforge.net/projects/libusb/files/libusb-1.0/libusb-1.0.9/libusb-1.0.9.tar.bz2
  • git clone https://github.com/gbishop/cython-hidapi.git

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 setup.py 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 setup.py file

  • wget http://weather.dragontail.co.uk/custom_download/setup.py -O setup.py

Copy the file libudev.so.0 and install

  • sudo cp /lib/arm-linux-gnueabihf/libudev.so.0 /usr/lib/arm-linux-gnueabihf/libudev.so
  • sudo python setup.py install

Step 4 - Install pywws

Install the latest version of pywws http://pypi.python.org/pypi/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