Rpi-weather

Instructions and support code for getting a cheap USB weather station connected to the Met Office wow.metoffice.gov.uk using a Raspberry Pi.

References Standing on the shoulders of giants...

View this Project on GitHub trastle/rpi-weather

Connecting the weather station to your Raspberry Pi

Connect your weather station

Connect your weather station to your Raspberry Pi using the USB cable provided. If you have misplaced the cable you should be able to pick up a replacement on Ebay by searching for “USB A male to male cable”. Once the weather station is connected try running the following command:

python ~/weather/pywws/code/TestWeatherStation.py

You will most likely see output very similar to the following error:

Traceback (most recent call last):
  File "/home/pi/weather/pywws/code/TestWeatherStation.py", line 179, in 
    sys.exit(main())
  File "/home/pi/weather/pywws/code/TestWeatherStation.py", line 114, in main
    ws = WeatherStation.weather_station()
  File "/home/pi/weather/pywws/code/pywws/WeatherStation.py", line 376, in __init__
    self.cusb = CUSBDrive(library)
  File "/home/pi/weather/pywws/code/pywws/WeatherStation.py", line 299, in __init__
    self.dev = USBDevice(0x1941, 0x8021)
  File "/home/pi/weather/pywws/code/pywws/device_pyusb.py", line 116, in __init__
    raise IOError("Claim interface failed")
IOError: Claim interface failed

Try running the same command prefixed with sudo (to run the as a super user):

 sudo python ~/weather/pywws/code/TestWeatherStation.py

The test will now succeed and you will see output similar to this:

0000 55 aa ff ff ff ff ff ff ff ff ff ff ff ff ff ff 1e 24 02 20 09 00 00 00 00 7f 00 42 02 00 10 25
0020 7d 28 52 28 00 00 00 00 00 00 00 10 01 13 12 33 41 23 c8 00 00 00 46 2d 2c 01 64 80 c8 00 00 00
0040 64 00 64 80 a0 28 80 25 a0 28 80 25 00 b4 00 00 68 01 00 04 00 c5 00 12 00 00 00 00 00 00 00 00
0060 00 00 61 0a 63 0c 3d 01 af 00 ef 01 60 00 ef 01 60 00 ea 00 51 80 76 28 02 26 20 29 ac 26 3a 03
0080 4b 03 6f 24 4b 8a 4b 8a 5d 8d 78 8d 00 13 02 02 08 28 13 02 02 08 17 12 11 29 21 35 13 01 15 03
00a0 05 10 01 01 12 00 12 10 07 09 32 10 01 02 09 53 10 01 01 14 29 10 01 02 09 53 10 01 01 14 29 12
00c0 11 29 21 35 13 01 15 03 05 13 01 04 11 27 12 12 14 15 45 13 01 04 11 27 12 12 14 15 45 10 01 02
00e0 09 53 10 01 02 09 53 12 09 27 15 09 12 09 27 22 20 12 09 27 22 20 12 10 19 16 31 13 01 24 09 37

The problem we are seeing is that the current user, ‘pi’, has no access to the weather station device. To rectify this we need to instruct udev to allow ‘pi’ access to the weather station:

wget https://raw.github.com/trastle/rpi-weather/master/udev/38-weather.rules
sudo mv 38-weather.rules /etc/udev/rules.d/.
sudo /etc/init.d/udev restart

Try running the test command again, this time you will observe that it works correctly without needing to run as a power user.

python ~/weather/pywws/code/TestWeatherStation.py

If the test command succeeds you are good to go. You now successfully have your Raspberry Pi talking to your weather station via pywws. If you are still seeing an error then try following the full udev weather station tutorial available weather-watch.com.

Next Step: Connecting your weather station to the MetOffice