This was my backup installation for Weewx and a La Crosse WS2350 Weather Station on a Raspberry Pi (RPi) after I suffered Python library problems with our Synology box. It is assumed you are running headless (no mouse, keyboard or monitor on the RPi) and have installed an SSH client on your main machine.
I started by getting a fresh version of the Raspbian OS from the Raspberry Pi website and then used the dd tools on my Mac to image the card. On the Weewx Google group there is a discussion on the life expectancy of card on the RPi and I would suggest taking an image of the card once you have everything set up should it fail. It would also be worth setting up some form of scp/rsync to copy your databases to a remote backup. You should also read the Raspberry Pi section of the Weewx website before starting.
Once you have plugged your RPi to the network and powered it up you will need to find it on your network. If you are using a linux based computer as your main machine then you can use something like
sudo nmap -sP 192.168.1.*
but windows will need some software like Advanced IP Scanner (untested).
I started by creating a new user for Weewx and added them to the superusers group so I have greater control over what the weather station can do.
sudo su adduser weewx usermod -a -G sudo weewx
Installing the Prerequisites
next I, patiently, worked through installing all the prerequisites.
# required packages: sudo apt-get install python-configobj sudo apt-get install python-cheetah sudo apt-get install python-imaging # required if hardware is serial or USB: sudo apt-get install python-serial sudo apt-get install python-usb # required if using MySQL: sudo apt-get install mysql-client sudo apt-get install python-mysqldb # optional for extended almanac information: sudo apt-get install python-dev sudo apt-get install python-pip sudo pip install pyephem
If you are installing Weewx onto the latest version of Raspbian then NTP is already installed. You can check this by checking the existence of the config file
and then checking that the correct time has been set with
if you get output that looks like Tue Dec 31 08:45:45 UTC 2013 then the time is set.
Installing and configuring Weewx.
Caveat from M:
Installation using the deb package is probably easier for most people with little linux experience. when you install using a deb package, dpkg will prompt for the altitude, lat/lon, station type, and any other required parameters. so there is little or no puzzling with config files when you install from deb package, at least for a generic installation.
However, for a manual or custom installation read on…
So download the latest version of Weewx onto your RPi and unzip it with
wget http://downloads.sourceforge.net/project/weewx/weewx-2.5.0.tar.gz tar -xvf weewx-2.5.0.tar.gz cd weewx-2-5.0
Next set the install path so weewx does not run in the home folder of the weewx user by opening the setup.cfg file with nano setup.cfg
# Set the following to the root directory where weewx should be installed home = /home/weewx/system25
with this done we can build the install (checking for errors) before running the install itself.
python setup.py build python setup.py install
If everything has gone to plan and Weewx has been installed into /homes/weewx/system25 we can now start configuring and running Weewx. You will want to configure: location; latitude; longitude; altitude; and station_type. This can all be done using vi or another text editor
Notes on station configuration
At the time of writing my station type (Technoline branded La Cross WS2350) was in Beta so I had to add WS23xx support manually. If you are working with version 2.5.1 or greater then you should be able to skip steps 1 to 3 and jump straight to 4.
1) download the ws23xx.py driver and the wee_config_ws23xx utility:
2) put the two files in the right place, set permissions on the utility:
cp ~/Downloads/ws23xx.py /home/weewx/bin/weewx/drivers cp ~/Downloads/wee_config_ws23xx /home/weewx/bin chmod 755 /home/weewx/bin/wee_config_ws23xx
3) add the ws23xx directives in weewx.conf:
[Station] station_type = WS23xx [WS23xx] port = /dev/ttyUSB0 driver = weewx.drivers.ws23xx
4) Check/ Update station interval.
When my reports first started to run I was getting dots and not lines as shown in the first part of the image. This was due the station interval time being set at 60 minutes.
If you are seeing something similar then you can check the station configuration and the hardware archive interval (‘hi’) using:
./bin/wee_config_ws23xx /home/weewx/system25/weewx.conf --info
you can set this interval with
sudo ./bin/wee_config_ws23xx /home/weewx/system25/weewx.conf --set-interval=5
and now you should have a working station.
Another caveat from M:
Another way to deal with the dots is to change the line_gap_fraction in skin.conf. some people might want to keep a long archive interval. for example, a long interval makes it possible to do weekly synchronization to stations with little memory. others simply do not need ‘live’ or even 5 minute updates of the data. reducing the value of line_gap_fraction will connect the dots without increasing the number of samples.
Now plug your station in to the RPi and check that is has loaded ok with the following command and you should see a listing for ttyUSB0
ls -l /dev/ttyUSB*
Depending on which user you intend to run the station as you might need to change the permissions of this file.
sudo chmod 664 /dev/ttyUSB0
although sadly unless you set up udev rules you might have to repeat this every time you unplug/replug the weather station.
Finally you can get down to running the station with
or if you want it to continue after you have logged off via SSH you will need to use nohup as shown below.
nohup ./bin/weewxd weewx.conf & echo $! > run.pid
this starts weewxd and then stores the pid in a file called run.pid for later when we would like to kill (stop) the weather station from running. We can check that the station is still running with
ps -e | grep "weewxd"
and now kill/stop it with
kill -TERM $(cat run.pid)
Viewing the output
You will be able to view output created on the RPi first by listing the contents of the public_html folder which is created inside your weewx system folder at the correct interval.
ls -la public_html
If you are playing with templates and have problems seeing updates I have had success deleting the public_html and starting over. Weewx will only create some first the first time so without the folder it starts over.
Assuming that folder exists you will want a web server to view those file. If you already have web space available then the easiest solution is to refer to the FTP section of the standard reporting section of the weewx.conf. You will need to restart weewxd if you make changes there.
If you want to install a webserver on the Raspberry Pi you start by getting the main apache package. As we are only viewing static pages there is no need for php or anything else.
sudo apt-get install apache2
Once this installation has completed you should be able to browse to the ip address of the RPi and see the standard it works! webpage. The easiest way to then view your actual weather pages is to create a link from the webroot to your weewx public_html folder:
cd /var/www sudo ln -s /home/weewx/system25/public_html weather
and then it should work!