...USB connection
...Installing weewx
...Upgrading weewx
...Configuration file
...Redirecting the logs
...Sending data to twitter
...Database tweaks
Other software

WMR 200



I run Weewx on a Raspberry Pi 2 (running Raspbian). The weather station (WMR200) is physically connected by USB to the Raspberry Pi 2 (version B). It communicates remotely with its sensors (rain etc).
The Raspberry Pi collects the data from the WMR's datalogger, stores them in its database and makes reports and weather graphs.
User group: Google Group

USB connection

You mustn't use usbhid, so it needs to be blacklisted: In /etc/modprobe.d/wmr200.conf
options usbhid quirks=0x0fde:0xca01:0x4
Then restart modprobe:
sudo modprobe -r usbhid
sudo modprobe usbhid
$ lsusb
Bus 001 Device 032: ID 0fde:ca01 

Installing weewx

You have the choice between:
  • a setup.py install - which works for 'any' OS
  • installation of the Debian package

setup.py install

sudo apt-get install python-configobj
sudo apt-get install python-cheetah
sudo apt-get install python-serial
sudo apt-get install python-imaging # Already present in most systems, but it doesn't
# hurt to install again.
sudo apt-get install python-usb # Required only for the Oregon Scientific WMR-USB
Then modify setup.cfg:
modify setup.cfg
./setup.py build
./setup.py install
You might want to run it in another home directory. Create the user:
$ adduser --home /home/weewx --disable-login weewx
$ chown weewx.staff /home/weewx
Then do in weewx directory:
./setup.py build
Optionally, ephem might be needed:
sudo python get-pip.py
sudo pip install pyephem
To start/stop weewx, use service weewx start/stop. However, it is important that NTP is synchronized before weewx starts. To do so, patch /etc/init.d/weewx:
     if [ $NPROC != 0 ]; then
        return 1
+    # Ensure NTP is up
+    if ! ntp-wait -n 20 -s 3; then
+        log_daemon_msg "Not starting $DESC: NTP not synchronised" "$NAME"
+        return 2
+    fi
and patch /usr/sbin/ntp-wait:
--- /usr/sbin/ntp-wait.orig     2013-11-30 21:27:55.016819640 +1000
+++ /usr/sbin/ntp-wait  2013-12-02 14:03:20.280256199 +1000
@@ -39,7 +39,7 @@
       if (/Connection refused/) {
        print "\bntpd is not running!\n" if ($opt_v);
-       exit 1;
+       last;
To boot weewx at startup:
sudo update-rc.d weewx defaults

Debian package

Retrieve the Debian package from the weewx website (download section). Then follow guidelines from the user documentation. The Debian package comes with start/stop scripts for the weewx daemon. The weewx.conf configuration file will be located in /etc/weewx.

Upgrading weewx

See doc

Configuration file


This is important to set to test your configuration and generate debug information:
debug = 1
The root path of weewx is essential
# Root directory of the weewx data file hierarchy for this station.
WEEWX_ROOT = /home/weewx/
I am using this version:
version = 3.2.1
You can set up some information about your weather station:
    # This section is for information about your station
    # Description of the station location.
    location = Bla bla
    # Latitude, longitude in decimal degrees
    latitude = 41.10
    longitude = 7.07611
    # Altitude of the station, with unit it is in. This is downloaded from
    # from the station if the hardware supports it.
    altitude = 100, meter    # Choose 'foot' or 'meter' for unit
The location, latitude, longitude, altitude will then be available in HTML templates as $station.location, $station.latitude, $station.longitude and $station.altitude.
You can also specify the URL for your weather station website:
    # If you have a website, you may optionally specify an URL for
    # its HTML server.
    #station_url = http://www.example.com
Then it is essential to set up the type of weather station:
    # Set to type of station hardware.  Supported stations include:
    #  Vantage   FineOffsetUSB  Ultimeter
    #  WMR100    WS28xx         WS1
    #  WMR200    WS23xx         CC3000
    #  WMR9x8    TE923          Simulator
    station_type = WMR200

    # This section is for the Oregon Scientific WMR200
    # The station model, e.g., WMR200, WMR200A, Radio Shack W200
    model = WMR200
    # The driver to use:
    driver = weewx.drivers.wmr200

    archive_interval = 300
Information can be sent to external websites that use RESTful protocols.
    # This section is for uploading data to sites using RESTful protocols.
        # To register this weather station, set this to True:
        register_this_station = False
This is to register the station on weewx station maps. Also, if your weather station is not published on websites such as AWEKAS, CWOP, you can disable those services:
  enable = false
Websites are known as 'reports'. You can set up several websites.
    # This section specifies what reports, using which skins, to generate.
    # Where the skins reside, relative to WEEWX_ROOT:
    SKIN_ROOT = skins
    # Where the generated reports should go, relative to WEEWX_ROOT:
    HTML_ROOT = public_html
    # Each subsection represents a report you wish to run:
        # What skin this report should be based on:
        skin = Standard

	skin = External
	HTML_ROOT = external_html
	     image_width = 600
	     image_height = 360
In the configuration above, I am creating two websites. One goes in public_html. And the other one, with bigger images, goes in external_html.
Uploading generated pages and images can be done via FTP, and this is yet another 'special' report.
        skin = Ftp
        # FTP'ing the results to a webserver is treated as just another report,
        # albeit one with an unusual report generator!
        # If you wish to use FTP, uncomment and fill out the next four lines:
        #user = replace with your username
        #password = replace with your password
        #server = replace with your server name, e.g, www.threefools.org
        #path = replace with the destination directory (e.g., /weather)
        # If you wish to upload files from something other than what HTML_ROOT
        # is set to above, then reset it here:
        #HTML_ROOT = public_html
        # Most FTP servers use port 21, but if yours is different, you can
        # change it here
        port = 21
        # Set to 1 to use passive mode, zero for active mode:
        passive = 1
        # How many times to try to transfer a file before giving up:
        max_tries = 2

        # Set to True for a secure FTP (SFTP) connection. Not all servers
        # support this.
        secure_ftp = False
I am located in Europe and want metric units everywhere including in my database.

    # should use US since that is what the wview database contains.
    target_unit = METRIC    # Options are 'US', 'METRICWX', or 'METRIC'


  radar_img = http://www.infoclimat.fr/api/AH4EMQcrAzhVYQQtVWdXNFw2BXhQOAEpDm0PZAc1AC8AYQIzVGcHNFFlVWIFNAdjAW9RM1EzBzNWNg5n/radar/sud_est?c6efb45b781de49d57c2c0aa20e8057c
  storm_img = http://www.meteorologic.net/map/radar/your_radar.php?lat=43.37
  radar_url = http://www.infoclimat.fr
I select units I like
    # This section is for managing the selection and formatting of units.
    group_rain         = mm                 # Options are 'inch', 'cm', or '
    group_rainrate     = mm_per_hour        # Options are 'inch_per_hour', '
cm_per_hour', or 'mm_per_hour'
    group_speed        = km_per_hour        # Options are 'mile_per_hour', '
Labels can be translated:
        # Generic labels, keyed by an observation type.
        barometer      = Barometre
        dewpoint       = Point de rosee
        heatindex      = Humidex
        inHumidity     = Humidite interieur
        inTemp         = Temperature interieure
        outHumidity    = Humidite exterieure
        outTemp        = Temperature exterieure
        radiation      = Radiation
        rain           = Precipitations
        rainRate       = Taux de precipitation
        rxCheckPercent = ISS Signal Quality
        windDir        = Direction du vent
        windGust       = Rafales
        windGustDir    = Direction rafales
        windSpeed      = Vitesse du vent
        windchill      = Temperature ressentie
        windgustvec    = Vecteur rafales
        windvec        = Vecteur vent
        foot              = " pieds"

    # The labels to be used for the phases of the moon:
    moon_phases = Nouvelle, Premier croissant, Premier quartier, Gibbeuse croissante, Pleine, Gibbeuse decroissante, Dernier quartier, Dernier croissant
The HTML files to generate are listed in:
        # Reports that show statistics "to date", such as day-to-date,
        # week-to-date, month-to-date, etc.
	    template = about.html.tmpl

	    template = almanac.html.tmpl
I want a humidity chart to be generated. This is specified in the ImageGenerator section:
Be sure to put the appropriate number of brackets. To optimize uploads to an external website, some resources need not be copied at each upload. This is handled by the copy_once directive in skin.conf:
copy_once = backgrounds/*, weewx.css, mobile.css, favicon.ico, smartphone/i\
cons/*, smartphone/custom.js

Customizing the time format

The customization of time formats to display in graphs or pages, is in skin.conf, section [[TimeFormats]]

Adding a UV sensor

To display UV index, in index.html.tmpl:
#if $day.UV.has_data
#end if
To generate a UV graph,
  • in skin.conf:
                yscale = 0, 16, 1
  • in the template index.html.tmpl:
    <a href="dayuv.png"><img src="dayuv.png"   alt="UV idx" title="Index UV" width="30%"/></a>

Adding a new graph

In skin.conf:
Then, in the html template (index.html.tmpl):
<img src="dayinouttemp.png" alt="temperatures" />


To generate a report (useful to test your skins):
To reload the configuration:
service weewx reload
To test your configuration:
sudo ./bin/weewxd weewx.conf

Redirecting the logs

By default, weewx logs are in /var/log/syslog. To redirect to another location, create a file in /etc/rsyslog.d, for example weewxlog.conf.
:programname,isequal,"weewx" /var/tmp/log/weewx.log
:programname,isequal,"weewx" ~
You need to restart rsyslog: service rsyslog restart.

Sending data to a twitter account

Download the extension from here and follow the configuration steps. In particular,
sudo apt-get install python-setuptools
sudo easy_install pip
sudo pip install twython
sudo setup.py install --extension weewx-twitter.x.y.tgz
See https://github.com/weewx/weewx/wiki/twitter In WEEWX_ROOT/bin/usr/twitter.py, modify to only send tweets at given time:
 ts = time.localtime()
        if (ts.tm_hour != 7 and ts.tm_hour != 14 and ts.tm_hour != 18):
            logdbg("This is not hour to tweet: %d" % ts.tm_hour)
In weewx.conf,
  • configure Twitter service:
        # This section is for uploading data to sites using RESTful protocols.
            app_key = to put here
            app_key_secret = to put here
            oauth_token = to put here
            oauth_token_secret = to put here
    	format = {dateTime:%X} Temp: {outTemp:%.1f} C; Humidite: {outHumidity:%.1f}%; Pression: {barometer:%.1f} hPa; Pluie: {dayRain:%.1f} mm; Vent: {windSpeed:%.1f} km/h; Dir: {windDir:%03.0f}; {windGust:%03.0f}
    	unit_system = METRIC
    	post_interval = 3600 
  • add twitter as a RESTful service:
        # This section configures the internal weewx engines.
        # It is for advanced customization.
        restful_services = weewx.restx.StdStationRegistry, weewx.restx.StdWunderground, weewx.restx.StdPWSweather, weewx.restx.StdCWOP, weewx.restx.StdWOW, weewx.restx.StdAWEKAS, user.twitter.Twitter

Database tweaks

The database that holds data is archive/weewx.sdb (unless you changed the name in the configuration file).
To retrieve the current temperature:
  1. Get the last entry by time: select max(dateTime) from archive;
  2. Read the inside temperature: select inTemp from archive where dateTime=...;
To retrieve the format of the archive database:
.schema archive
CREATE TABLE archive (`dateTime` INTEGER NOT NULL UNIQUE PRIMARY KEY, `usUnits` INTEGER NOT NULL, `interval` INTEGER NOT NULL, `barometer` REAL, `pressure` REAL, `altimeter` REAL, `inTemp` REAL, `outTemp` REAL, `inHumidity` REAL, `outHumidity` REAL, `windSpeed` REAL, `windDir` REAL, `windGust` REAL, `windGustDir` REAL, `rainRate` REAL, `rain` REAL, `dewpoint` REAL, `windchill` REAL, `heatindex` REAL, `ET` REAL, `radiation` REAL, `UV` REAL, `extraTemp1` REAL, `extraTemp2` REAL, `extraTemp3` REAL, `soilTemp1` REAL, `soilTemp2` REAL, `soilTemp3` REAL, `soilTemp4` REAL, `leafTemp1` REAL, `leafTemp2` REAL, `extraHumid1` REAL, `extraHumid2` REAL, `soilMoist1` REAL, `soilMoist2` REAL, `soilMoist3` REAL, `soilMoist4` REAL, `leafWet1` REAL, `leafWet2` REAL, `rxCheckPercent` REAL, `txBatteryStatus` REAL, `consBatteryVoltage` REAL, `hail` REAL, `hailRate` REAL, `heatingTemp` REAL, `heatingVoltage` REAL, `supplyVoltage` REAL, `referenceVoltage` REAL, `windBatteryStatus` REAL, `rainBatteryStatus` REAL, `outTempBatteryStatus` REAL, `inTempBatteryStatus` REAL);

sqlite> .schema archive_day_rain
CREATE TABLE archive_day_rain (dateTime INTEGER NOT NULL UNIQUE PRIMARY KEY, min REAL, mintime INTEGER, max REAL, maxtime INTEGER, sum REAL, count INTEGER, wsum REAL, sumtime INTEGER);
You can perform queries/commands on the database:
select dateTime, rain, rainRate, rainBatteryStatus from archive where dateTime >= 1439157600 and dateTime < 1439244000
sqlite> select * from archive_day_rain where dateTime >= 1439157600 and dateTime < 1439244000
   ...> ;
Note that:
  • My database uses the Metric system: 16 is for Metric.
    sqlite> select dateTime, usUnits, rain, rainRate from archive where rain > 0 and dateTime > 1428271200 and dateTime < 1428357600;
  • The units for rain is CENTIMETERS (not mm)
To fix an incorrect value in the database:
  1. stop weewx: sudo service weewx stop
  2. backup weewx.sdb (just in case, but safe!)
  3. update the rows as desired:
    update archive set rain=0.02 where dateTime=XXX;
  4. drop the daily summaries:
    wee_config_database weewx.conf --drop-daily
  5. If necessary, delete the NOAA for the affected month and year (in public_html/NOAA/)
  6. The rows will rebuild correctly when weewx is restarted. If you don't want to wait, you can do it offline:
    wee_database weewx.conf --backfill-daily
  7. restart weewx: sudo service weewx start.

Other software