See the main page for the WxTools overview
This program is intended for logging the data transmitted by a Fine Offset WH2900 (http://www.foshk.com/Wifi_Weather_Station/WH2900.html) or one of its clones such as the Pro-Signal PSG04173. The program is likely to valid for a number of other Fine Offset weather stations and their clones (Ambient, Ecowitt, Watson, etc.). The data is sent over a WiFi link to a computer (desktop or embedded). The name WxServer derives from the common abbreviation WX for "weather conditions".
Several other programs are also available such as Cumulus, Weather Station Data Logger and WeeWx. So why create yet another weather station program? The aim was to use Java so that WxServer could run on a large variety of systems. There was also a need for only simple data logging, without more advanced features such as graphical display or uploading data to a remote site. It was also desirable to create an open-source program that could be readily customised by others.
WxServer 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). WxServer is currently being run on a Raspberry Pi. Support for running the code includes Oracle Java and OpenJDK.
The program is designed only for logging - not real-time display or data upload. If invalid or void measurements are received from the weather station, they are ignored. The author has created WxDisplay and WxChart to display historical data. 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 radio 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.
Optionally setting mail configuration parameters will allow significant issues (regular data loss, low battery) to be reported by email. Likely program customisations involve changing the following in the associated properties file (WxServer.properties):
In addition, the following constants in the code might be changed (requiring the code to be recompiled):
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. The data that is logged hourly is as follows:
HH:MM time NN.N wind speed NNN wind direction NN.N outdoor temperature NN outdoor humidity NNNN.N absolute pressure NN.N outdoor rainfall total since midnight NN outdoor UV index NNNN.N outdoor solar radiation
The WxServer.java code is provided in source form, but has been pre-compiled for Java 17 into the JAR wxserver.jar. The files can be placed anywhere in the file system.
WxServer.java can be run automatically started on Linux. The wxserver-init script should be modified appropriately and saved as /etc/init.d/wxserver, while the wxserver-run script should be modified appropriately and saved as /usr/local/bin/wxserver (say). WxServer.java can then be manually stopped by root using systemctl stop wxserver and manually started by root using systemctl start wxserver.
WxServer can be run with:
java -jar lib/wxserver.jar
However if WxServer is run on a lower-numbered port (below 1024) and is not run by root, this requires special treatment on Linux. Install authbind and configure it to allow binding to this port. WxServer would then be run with:
authbind --deep java -jar lib/wxserver.jar
The program can be run interactively from a console. It can also be run as a background service (Windows) or startup program (Unix). When the program runs interactively, typing '0' to '3' will change the logging level: 0 nothing, 1 hourly data, 2 also sensor data, 3 also web requests. 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 when a WiFi message arrives, so the program may take up to a minute to react.
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 the total 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, 10 high) NNNN.N outdoor solar radiation (W/m2)
This format is compatible with that used by the original WeatherView software supplied by Oregon Scientific, except that measurements finish with an indoor dewpoint, a UV index and solar radiation. Another difference is that rainfall is cumulative for each day since midnight. The log format could be customised by changing method logMeasures.
Wind chill and dewpoint are calculated as they are not supplied via WiFi. The wind chill is calculated from the North American/UK formula. The dewpoint is calculated from the Sonntag formula.
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.
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 3 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.
Version 1.0: First public release, Ken Turner, 3rd March 2021