WxLog
(Oregon Scientific WMR928 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 WMR928N). The data is sent over an RS232 serial port link to a PC. The name WxLog derives from the common abbreviation WX for "weather conditions".

Oregon Scientific supply the WeatherView program with the weather station, so why bother to write anything else? The problem is that WeatherView runs only on MS Windows. You cannot run the software on an old DOS system (as I have done), on MacOS, on Linux, etc. The idea is therefore to provide more portable computer support for the weather station.

Boris Pasternak also developed WMR928 support in C for Linux.

Why is the program written in QuickBasic? I did this so that it could be run on an old PC or laptop that was no use for anything else. QuickBasic (or QB) was provided with MS DOS, and in MS Windows up to around Windows 98. Options for running this code on Windows include:

QuickBasic:
Use a copy from an older version of MS DOS or MS Windows. QuickBasic will run in 16-bit mode under Windows XP (and possibly later versions). The code can be run from a DOS prompt with:
      qbasic wxlog.bas
    
QBasic:
QBasic can compile code to an executable with "Run > Make EXE File" (optionally making it free-standing). The code can then be run from a command prompt with:
      qb wxlog.bas
    
QB64:
QB64 is close, but may not handle serial ports compatibly with QuickBasic. Console files may also not be supported.

FreeBasic:
FreeBasic is unfortunately not close enough to QuickBasic to compile the code as currently written.

QuickBasic is an old dialect of Basic, but it should not be too difficult to convert for other systems. For example, it should be fairly easy to convert the program to run under MS Visual Basic. The program is written in a structured manner (and well commented!), so it should be fairly easy to convert it to other languages such as C, C#, Java, Perl or Python. The only porting issues are likely to be handling raw serial port data and keystrokes.

The main problem in developing this program was that the protocol used by the weather station is unpublished. The author tried to discover this by patient observation and inspired guesswork. See the interface specification for the details.

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

The program deals with some unusual situations that can arise. It is possible, for example, to receive two messages for the same hour. This probably happens because the radio clock can reset the time back to the previous hour. The program also logs the cumulative rainfall each day. Since this relies on the cumulative rainfall since the weather station rainfall memory was reset, it is necessary to handle a reset while the program is running.

The outdoor temperature/humidity sensor is normally the main one (channel 0). However, this data can instead be logged from an additional outdoor sensor (channel 1 to 3). This may be necessary because the original THGR918N sensor appears have been discontinued. The THGR228N is an approximate replacement as it works only on channels 1 to 3. If the main sensor is not used, the base station does not calculate the wind chill temperature. WxLog therefore performs the wind chill calculation for an additional sensor and logs it.

Note that the program does not handle a change in hour due to daylight saving starting or ending. It will be necessary to edit the log manually to correct for this.

Customisation

Note that the original QuickBasic (at least) is restricted to using ports COM1 and COM2. If you do not have these, you should be able to emulate them with a USB serial port. On Windows, use Properties in Device Manager to set the port number to COM1 or COM2.

Customisation is possible by changing the following constants in the code:

archive
at midnight, archive the current day's log to a drive (e.g. a floppy or memory stick) which must be available; this is for a DOS system that continues to run while data is logged [default 1, i.e. archive]
backup
when archiving, backup the current day's log as "LAST_DAY.DAT"; this file must previously have existed as it will be deleted and recreated [default 0, i.e. do not back up]
drive
drive letter to use for archives [default A]
interval
set this to the number of minutes between log entries, which must be a submultiple of 60 [default 15, i.e. 00/15/30/45 minutes past the hour]
outdoor
set this to the channel number for the outdoor temperature sensor; readings from other outdoor temperature sensors will be ignored [default 0 = main sensor, 1 = sensor 1, 2 = sensor 2, 4 = sensor 3]
port
set this to the serial port number [default 1 = COM1]
report
reporting level verbosity; this setting can be changed at run-time by pressing numeric keys 0 to 3:
      0   no output (permanently disables screen/keyboard when set initially)
      1   output averages to screen at the end of each hour [default]
      2   1 plus output values to screen on each measurement
      3   2 plus output message hex display to screen on each message
    

Hourly summaries on-screen provide:

    HH:MM           time
    NN.N NNN        wind speed and direction averaged during the past hour
    NN.N NN NNNN    outside temperature, humidity and pressure averaged
		    during the past hour
    NN.N            rainfall total since midnight
  

Usage

The wxlog.bas program is provided in source form. Store it where you wish. Enter QuickBasic and run it, or write a short batch file that does qbasic /run wxlog.bas.

A 16-bit Windows executable (compiled with QBasic) is also provided. wxlog.exe has all configuration parameters set to the default, and is suitable for normal use. For use as a Windows service (in conjunction with WxList), recompile with backup as 1 and report as 0.

Data is logged to a file named "YYYYMMDD.DAT" and contains the following fields separated by one or more spaces. Values are calculated for each logging interval, except rainfall which is totalled since midnight. Each interval generates a line as follows in the log file. The numbers refer to fields, counting from 0 as the start.

    HH:MM:SS             time of log (0)
    NN.NN NN.N NN.N      wind speed average/minimum/maximum (1-3, m/s)
    NNN NNN NNN          wind direction average/minimum/maximum (4-6, °)
    NN.N NN.N NN.N       outdoor temperature average/minimum/maximum (7-9, °C)
    NN NN NN             outdoor humidity average/minimum/maximum (10-12, %)
    NN.N NN.N NN.N       outdoor dewpoint average/minimum/maximum (13-15, °C)
    NNNN.N NNNN.N NNNN.N absolute pressure average/minimum/maximum (16-18, mb)
    NN.N NN.N NN.N       indoor temperature average/minimum/maximum (19-21, °C)
    NN NN NN             indoor humidity average/minimum/maximum (22-24, %)
    NN                   rainfall total since midnight (25, mm)
    NN.N NN.N NN.N       wind chill temperature average/minimum/maximum (26-28, °C)
    NN.N NN.N NN.N       indoor dewpoint average/minimum/maximum (29-31, °C)
  

This format is compatible with that used by the WeatherView software supplied with the weather station, except that measurements finish with an indoor dewpoint (which is not used by WeatherView). In addition, WeatherView logs cumulative rainfall since the base station memory was cleared; instead, WxView logs cumulative rainfall since midnight.

To quit the program, press Escape; when prompted, press Escape again. This will return you to QuickBasic. Leave QuickBasic with Alt-F then X. The verbosity level can be changed during running by pressing keys 0 to 3. Note that the response to keystrokes is slow because the program has to wait for the next input over the serial port to be completed.

The separate program wxmove (a Perl script) is included to help with moving data files from floppy disc to the hard disc of another PC.

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.1: First public release, Ken Turner, 8th May 2003

Version 1.2: Ken Turner, 26th January 2004

Version 1.3: Ken Turner, 7th July 2005

Version 1.4: Ken Turner, 29th December 2005

Version 2.0: Ken Turner, 20th June 2009

Version 2.1: Ken Turner, 5th September 2011

Version 2.2: Ken Turner, 27th November 2011

Version 2.3: Ken Turner, 18th February 2013

Version 3.0: Ken Turner, 13th February 2017