Installation of Pywws on Raspberry Pi 2 for Weather Station

This is the process I followed to install pywws on a Raspberry Pi 2 on Raspian.  I have a 3080 compatible weather station connected to the Raspberry Pi 2 via USB.

Install Dependencies

As pywws is written in Python, it has a few dependencies which need to be installed on the Raspberry Pi 2.  I like to make sure that before this I update to the latest updates.

Now install the python, libusb and gnuplot.  Libusb as we need to access the weather station via USB and gnuplot in order for draw graphs with pywws.

There are other dependencies if you want to use other features or pywws (eg. twitter), but these will give you the basics to get pywws up and running.  Other dependencies can be found here.

Install Pywws and permissions

After all the required software is installed, you can install pywws.

After it has installed, plug in the internal weather station unit to the Raspberry Pi 2 via USB. Now you can test to ensure it can talk to the weather station.

This command should produce some output that looks like this.

If this does not work, further information is available at http://jim-easterbrook.github.io/pywws/doc/en/html/guides/getstarted.html which may help. You have to run pywws in python using sudo. It is much better to run it as the user Pi and the give the Pi user access to the USB port. First create a group to grant the access and add the Pi user to the group

You need to identify the idVendor and idProduct for your WeatherStation that is plugged into the USB port. Look into the kernal log file.

Look for idVendor and idProduct, mine were idVendor=1941 and idProduct=8021. My kern.log look like this.

To modify the USB, create a rule that sets the usb port to the group weather

Copy and paste the following into this file. Make sure you update the idVendor and idProduct to suit your USB.

After you’ve saved and exit, reboot the Pi. Once the Pi has started again, test connecting to the weatherstation as user Pi, without sudo.

You should get the same results as you did above when you tested using the command with sudo. As we’ll be running this as user Pi, ensure that all the weather data is owned by user Pi.

Configuration of Pywws

I wanted readings every 5 minutes from the weather station and as pywws can easily read and log the weather station data every 5 minutes (recommended setting is 5min too), this was ideal. So, I set the weather station to log every 5 minutes.

It’s worth noting that the memory in the internal unit is not very large and although it will buffer some data, it cannot hold very much weather data. Now to setup where to log the data.  I chose /home/pi/data/weather, but it could be anywhere.  If a different directory is used, update the url through the rest of this page to the select directory.

All the weather station’s logged data should go into this directory. As per the getting started doco above for pywws, we now need to setup the timezone and weather station type. We will need to run the following command and it will create the configuration files the first time it is run.

The configuration files are found in the data directory /home/pi/data/weather/data. I adjusted the following in the weather.ini configuration file.

There is a full page in the doco about the weather.ini configuration settings here. I also update the configuration paths in the weather.ini file.

My full weather.ini looks like this.

Now create these directories and copy the pywws examples into them.

Then we run the command again.

This will probably need to run for a while to download the data. It should have some output similar to this.

So now that the weather station data can be downloaded, I want to setup a service that will run to download the weather data. There are two options, an hourly update or a live logger. I opted for the live logger as I wanted data updated as close to every 5min as possible. Pywws comes with a livelogger than can run as a daemon.  It can be run like this.

While this works well, it will not start automatically. A service init script is much easier to manage for me. Create a new init.d file by running the following.

Now copy and paste the following into this file. Update the DAEMON, DATADIR and LOGFILE to suit your installation.

Once the init script has been saved, it needs to be made executable and added to rc.d so it will start and stop at startup and shutdown.

You can also start/stop pywws as a service.

References

http://www.weather-watch.com/smf/index.php?topic=39257.0
https://jim-easterbrook.github.io/pywws/doc/en/html/index.html
https://groups.google.com/forum/#!topic/pywws/r9KfWM_AgKY
https://github.com/borpin/pywws-scripts/blob/master/pywws-livelog