How to configure pywws

Following on from the tutorial on how to install the libaries and connect a Maplin Weather station to the Raspberry Pi. I have included below some pointers on how to configure pywws. This does not replace the excellent instructions provided by Jim Easterbrook at , but highlights some of the areas that may be missed or that are specific to the Raspberry Pi.


That you have successfully run the python script TestWeatherStation shown in the previous tutorial

Step 1 - Accessing the USB as pi user

When running TestWeatherStation we needed to add sudo before python. It is much better to run as the pi user. To give the pi user access to the usb port:

Create a new group called weather and add pi user to the group

  • sudo addgroup --system weather
  • sudo adduser pi weather

Check the idVendor and idProduct for the WeatherStation by disconnecting from the pi, running

  • tail -f -n 0 /var/log/kern.log

then reconnecting the station
Press Ctrl C to finish the kernal log monitoring
Look for idVendor=1941 and idProduct=8021. These may be different for different Weather Stations, but identify the station thats plugged into the usb port.
Create a rule that sets the usb port to the group weather

  • sudo nano /etc/udev/rules.d/39-weather-station.rules

Add the following lines changing the idVendor and idProduct if required

  • ACTION!="add|change", GOTO="station_end"
  • SUBSYSTEM=="usb", ATTRS{idVendor}=="1941", ATTRS{idProduct}=="8021", GROUP="weather"
  • LABEL="station_end"

Save and exit, then restart the RPi
Test the weather station connection again without sudo

  • python -m pywws.TestWeatherStation

Step 2 - Additional Libraries

In order to connect to twitter and produce graph plots you will need to install the following:

  • cd ~
  • sudo pip install python-twitter
  • sudo pip install oauth2

And to use the graphs you will need gnuplot

  • sudo apt-get install gnuplot

To use secure ftp transfer you will need

  • sudo apt-get install python-paramiko
  • sudo apt-get install python-pycryptopp

Step 3 - Directories

Assuming pywws is installed using pip
A directory is required to store the text and graphics templates, separate from the examples so that I could always refer to them and they won't be over written.

  • mkdir ~/weather
  • cp -R /usr/local/lib/python2.7/dist-packages/pywws/examples/* ~/weather

We will also need a data directory to store the weather.ini and processed weather data

  • mkdir ~/weather/data
  • mkdir ~/webdata

Finally there needs to be a directory to store the web pages created from the templates

  • mkdir /home/pi/weather/temp

Next - weather.ini