pywws.weatherstation

Get data from WH1080/WH3080 compatible weather stations.

Derived from wwsr.c by Michael Pendec (michael.pendec@gmail.com), wwsrdump.c by Svend Skafte (svend@skafte.net), modified by Dave Wells, and other sources.

Introduction

This is the module that actually talks to the weather station base unit. I don’t have much understanding of USB, so copied a lot from Michael Pendec’s C program wwsr.

The weather station memory has two parts: a “fixed block” of 256 bytes and a circular buffer of 65280 bytes. As each weather reading takes 16 bytes the station can store 4080 readings, or 14 days of 5-minute interval readings. (The 3080 type stations store 20 bytes per reading, so store a maximum of 3264.) As data is read in 32-byte chunks, but each weather reading is 16 or 20 bytes, a small cache is used to reduce USB traffic. The caching behaviour can be over-ridden with the unbuffered parameter to get_data and get_raw_data.

Decoding the data is controlled by the static dictionaries _reading_format, lo_fix_format and fixed_format. The keys are names of data items and the values can be an (offset, class, kwds) tuple or another dictionary. So, for example, the _reading_format dictionary entry 'rain' : (13, WSFloat, {'signed': False, 'scale': 0.3}) means that the rain value is an unsigned short (two bytes), 13 bytes from the start of the block, and should be multiplied by 0.3 to get a useful value.

The use of nested dictionaries in the fixed_format dictionary allows useful subsets of data to be decoded. For example, to decode the entire block get_fixed_block is called with no parameters:

ws = pywws.weatherstation.WeatherStation()
print(ws.get_fixed_block())

To get the stored minimum external temperature, get_fixed_block is called with a sequence of keys:

ws = pywws.weatherstation.WeatherStation()
print(ws.get_fixed_block(['min', 'temp_out', 'val']))

Often there is no requirement to read and decode the entire fixed block, as its first 64 bytes contain the most useful data: the interval between stored readings, the buffer address where the current reading is stored, and the current date & time. The get_lo_fix_block method provides easy access to these.

For more examples of using the pywws.weatherstation module, see the pywws.testweatherstation module.

Detailed API

Classes

CUSBDrive()

Low level interface to weather station via USB.

DriftingClock(name, status, period, margin)

WSBits

WSDateTime

WSFloat([x])

WSInt

WSStatus

WSTime

WeatherStation([context])

Class that represents the weather station to user program.


Comments or questions? Please subscribe to the pywws mailing list http://groups.google.com/group/pywws and let us know.