WxLogger
(Oregon Scientific WMR180 Data Logger)

Weather Symbol

See the main page for the WxTools overview

Description

This program is intended for logging the data transmitted by an Oregon Scientific Professional Weather Station (model WMR180). The data is sent over a USB link to a computer (desktop or embedded). The name WxLogger derives from the common abbreviation WX for "weather conditions".

Oregon Scientific supply the Virtual Weather Station program. Several other programs are also available such as Cumulus, Weather Station Data Logger and WeeWx.

So why create yet another weather station program? I wished to use Java so that WxLogger could run on a large variety of systems. I needed only simple data logging, without more advanced features such as graphical display or uploading data to a remote site. I also wanted to create an open-source program that could be readily customised by others.

The weather station USB interface is treated as a HID (Human Interface Device). WxLogger relies on JNI (Java Native Interface) code provided by the JavaHIDAPI project.

WxLogger has been run on Linux (ARM, 32-bit) and MS Windows (XP/7/10, 32/64-bit), but should run on a number of other systems (Linux Intel 32/64-bit, MacOS Intel 32/64-bit). I am currently running WxLogger on a Raspberry Pi.

Options for running the code include Oracle Java and OpenJDK.

The code is based on the discoveries by others of the weather station protocol. See the interface specification for the details. Although that work mostly concerns the WMR100, it appears to be relevant to the WMR180 (and probably also the WMR88). WxLogger will probably therefore work for all of these weather stations, though not the WMR200.

The program is designed only for logging - not real-time display or data upload. The author has created WxDisplay and WxChart to display historical data using an applet. Command-line scripts also allow data to be extracted in various ways.

The program tries to cope with some unusual situations that can arise. It is possible, for example, to receive two messages for the same hour if the Internet clock corrects the time. On changing to or from daylight saving time, the clock will go forward or back. This results in a missing hour of data or a double hour of data respectively.

Customisation

If you can live with the program defaults, you just need a JVM (Java Virtual Machine). If you wish to change the defaults or to alter the code, you also need a JDK (Java Development Kit).

Customisation is possible by changing the following constants in the code ("customisation" section):

ARCHIVE_PATH
directory path for archive files (default '/tmp', must not be '.', or end with '/' or '\'); if empty, no archiving takes place (i.e. log files remain in their original place)
BACKUP_LOG
when archiving, preserve the current day's log as 'LAST_DAY.DAT' (default true, i.e. do backup); the last day's log file will be replaced if it exists
DEGREE
degree symbol (default Unicode degree); this may need to be set to empty if the console does not support Unicode
LOG_DEFAULT
default flags for log output as logical OR of individual log flags (default hourly data, for 0 nothing, 1 USB data, 2 frame data, 4 sensor data, 8 hourly data)
LOG_FILE
name of a log file to use, or empty to mean output to the console (default empty)
LOG_INTERVAL
the number of minutes between log entries (default 15, i.e. 00/15/30/45 minutes past the hour); the value must be a submultiple of 60 (e.g. 10, 15, 20, 30)
OUTDOOR_SENSOR
outdoor temperature sensor to log (default 1)

Error messages and the following hourly summaries can appear in the log output. Hourly figures are averages for the past hour, except for rainfall which is cumulative. Indoor or outdoor sensor data is followed by '?' if there is missing data for the corresponding sensor. Outdoor sensor data is followed by '!' if the corresponding sensor battery is low.

    HH:MM    time
    NN.N     wind speed
    NNN      wind direction
    NN.N     outdoor temperature
    NN       outdoor humidity
    NNNN     absolute pressure
    NN.N     outdoor rainfall total since midnight
    NN       outdoor UV index
  

Installation

As a convenience, interface code is included from JavaHIDAPI project.

The WxLogger.java code is provided in source form. This has been pre-compiled for Java 6 along with the Java HID code into the JAR wxlogger.jar. This is supported by the hidapi native library. Find the appropriate library file under the res directory and install it. On Windows, for example, this requires creating hidapi.dll under \Windows\system32. On Linux, for example, this requires creating libhidapi.so under /usr/lib. Note that WxLogger.java refers to the library as hidapi so any suffix like '-jni-32' must be omitted in the installation name.

Usage

Run WxLogger.java as follows:

    java -cp lib/wxlogger.jar uk.ac.stir.cs.wx.WxLogger
  

The program can be run interactively from a console. It can also be run as a background service (Windows) or startup program (Unix).

A file for each day is created in the current directory with the name 'YYYYMMDD.DAT' (e.g. '20130131.DAT'). It contains the following fields separated by one or more spaces. Values are calculated for each logging interval, except rainfall which is totalled since the previous midnight.

    HH:MM:SS               time of log
    NN.N NN.N NN.N         wind speed average/minimum/maximum (m/s)
    NNN NNN NNN            wind direction average/minimum/maximum (deg from N)
    NN.N NN.N NN.N         outdoor temperature average/minimum/maximum (C)
    NN NN NN               outdoor humidity average/minimum/maximum (%)
    NN.N NN.N NN.N         outdoor dewpoint average/minimum/maximum (C)
    NNNN.N NNNN.N NNNN.N   absolute pressure average/minimum/maximum (mb)
    NN.N NN.N NN.N         indoor temperature average/minimum/maximum (C)
    NN NN NN               indoor humidity average/minimum/maximum (%)
    NN                     rainfall total since midnight (mm)
    NN.N NN.N NN.N         wind chill temperature average/minimum/maximum (C)
    NN.N NN.N NN.N         indoor dewpoint average/minimum/maximum (C)
    NN NN NN               UV index average/minimum/maximum (0 low, 6 high, ...)
  

This format is compatible with that used by the original WeatherView software supplied by Oregon Scientific, except that measurements finish with an indoor dewpoint and a UV index. Another difference is that rainfall is cumulative for each day since midnight. The log format could be customised by changing method logMeasures.

The wind chill is normally calculated when an anemometer reading is received. If an outdoor temperature has been received and the wind speed is high enough, the wind chill is calculated from the North American/UK formula. If an outdoor temperature has been received but the wind speed is not high enough, the wind chill is set to the outdoor temperature. If an outdoor temperature has not been received and the weather station wind chill is invalid, the wind chill is set to zero (which may result in the first such value being incorrect).

When the program runs interactively, entering '0' to '4' will change the logging level from nothing to everything. Entering '.' twice in succession will exit the program. Note that a keyboard entry must be followed by Enter before it is processed. Keyboard entry is checked only every 10 to 20 seconds approximately (depending on the length of the main loop).

The separate program wxmove (a Perl script) is included to help with moving data files from a memory stick or network drive to the hard disc of another computer.

Licence

This program is free software. You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation - either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful but without any warranty, without even the implied warranty of merchantability or fitness for a particular purpose. See the GNU General Public License for more details. You may re-distribute this software provided you preserve this README file.

History

Version 1.0: First public release, Ken Turner, 18th February 2013

Version 2.0: Ken Turner, 13th February 2017