Custom Feeds of Logged Weather Data


This is more of an advanced topic and one which typically won’t be of any relevance at all to most prospective owners of a new weather station. But in case anyone is considering buying a PC-linked weather station with a specific view to generating a feed of weather data for input to other software programs, here is a summary of the options.

First, let’s make it clear that it is indeed feasible to use a Davis station and Weatherlink data logger as a source of data for other software applications. Specifically, it’s possible to write custom applications that use the weather data and that are designed to perform tasks that go beyond the standard features of the Weatherlink software and of comparable third party programs, including potentially the control of external equipment according to prevailing weather conditions.

There are a number of ways in which custom software can interact with the Weatherlink hardware and software, the one overriding requirement being that the Weatherlink data logger must be installed if Davis weather stations are realistically to supply data to other programs (though please note that this does not necessarily imply use of the Weatherlink software). Broadly, there are three approaches for accessing weather station data, which are explained in a little more detail below:

  • Communicating with the data logger directly (and bypassing the Weatherlink software);
  • Manually exporting data from within the Weatherlink software;
  • Automatically reading data generated by the Weatherlink software;

Using most of these options requires writing further programs to link to the Weatherlink logger and/or software and is therefore likely to appeal only to those users comfortable with writing program code. (This does not apply to manual data export, which is much more straightforward and can be used by anyone familiar with say reading data from a text file into a spreadsheet program such as Excel.) To write your own program obviously requires knowledge of the technicalities of the logger and software interfaces, which we haven’t got space to cover in detail here. But this is a specific area of expertise for us here at Prodata, and we will be happy to advise further on request – advice is usually free. We’re also available to accept commissions for the development of specific add-on utilities for the Weatherlink logger and software – please contact us for further discussion.

Direct interface to the data logger

As detailed elsewhere, the Weatherlink data logger interfaces to a PC via a standard RS232 serial port. Technical information about the protocol used by the logger to return different types of data record is published by Davis in sufficient detail to allow programmers to write their own software to interact directly with the logger interface. For this type of custom program, the Weatherlink software doesn’t even need to be installed – unlike the manual and automated export of data described below which rely completely on  the main Weatherlink program.

The chief advantage of direct logger communication is that a custom program can interrogate the logger interface for just those elements of data that are required for its purpose and at a frequency of its choosing (subject to the design limitations of the logger of course). Data does not need to be pre-processed by the Weatherlink software with any delays and drawbacks that might be involved. Another benefit is that talking direct to the serial interface places no constraint on the PC operating system used. So for example it is perfectly possible to program for operation under Linux.

Besides this direct logger interface, Davis also provide a Windows DLL that can manage much of the low-level communication with the logger interface. This can be quite a good compromise in offering much of the flexibility of talking direct to the interface while freeing the programmer from needing to handle all the detail of retrieving individual data items.

The main drawback of direct interaction arises from the fact that under Windows only one program can access the serial port at any one time. So if a custom program is talking to the logger then the Weatherlink software can’t simultaneously be collecting data. So, in practice, having a custom logging program permanently active means that the Weatherlink software can’t be used. (Except possibly if the custom program is terminated temporarily at periodic eg daily or weekly intervals just to allow the Weatherlink software to perform an archive download).

The downside of not using Weatherlink at all is that a custom program will need to be designed to manage all of its own data. Weatherlink actually does a good and unobtrusive job of maintaining its main archival database of all logged weather data and of making that data available for analysis and review. A custom program would need to duplicate much of this functionality to be a true alternative to Weatherlink and writing such a program is not a trivial task. So before deciding to opt for a program that talks directly to the logger, a developer should consider whether allowing Weatherlink to be the main data manager and sourcing an indirect feed of data from the Weatherlink software rather than direct from the logger might not be a better option.

Manual export of data

Any reasonably experienced Windows user should be able to export weather data manually from within the Browse mode of the Weatherlink software, without needing to do any programming at all. All that’s required is to select ‘Export Records’ from within the Browse window menus and to choose the required range of dates.

Complete records (ie containing data for all logged sensors) of weather data are extracted from the archive database for each day in the selected date range and exported to a tab-delimited text file. Note that because this exported data is copied from the main database only, it will include the same level of time detail as set for the archive interval. In other words, if the software is set to log data at say hourly intervals, then the exported data will contain 24 records per day at hourly intervals; there’s no mechanism to export data other than from the archive database.

Once the tab-delimited text file has been created, this can be imported into any compatible software application. A typical use at the beginning of each month might be to import the whole of the previous month’s data into a spreadsheet program such as Excel and to calculate whichever monthly parameter totals and means the user might prefer. But the process is of course completely flexible. Once the text file has been created by Weatherlink it can be read into any compatible program and used for any data analysis task imaginable.

Automated data reading

Automated reading of data from the Weatherlink software is probably the most interesting and useful means for developers to create a custom feed of weather data. But first we should confirm that the Weatherlink software has no known methods for passing data in-memory, eg via COM or even DDE interfaces. (It’s conceivable that such features exist but are publicly undocumented, or that a future release of Weatherlink may introduce such features, but for now and at least as of Weatherlink v5.5, there seems to be no available in-memory interface to the Weatherlink data.) As a consequence, the only mechanism we can use to create an external data feed is to read one or more of the disk files that Weatherlink creates.

Fortunately, there are a number of different files that Weatherlink can be set to maintain and update automatically, including:

  • The main monthly archive database files; (Note that these are not text files, but are in a published binary format);
  • Text files in a similar comprehensive format to the manually exported text files, but generated automatically and covering periods of 24-48 hours or 7-8 days;
  • Other custom files;

Any of these file types can be used as a source of data for other programs, provided care is taken to avoid collisions with Weatherlink in accessing a particular file.