WeatherStation
index
WeatherStation.py

WeatherStation.py - get data from WH1080 compatible weather stations
 
Derived from wwsr.c by Michael Pendec (michael.pendec@gmail.com) and
wwsrdump.c by Svend Skafte (svend@skafte.net), modified by Dave Wells.

 
Modules
       
Localisation
math
platform
usb

 
Classes
       
weather_station

 
class weather_station
    Class that represents the weather station to user program.
 
  Methods defined here:
__del__(self)
Disconnect from weather station.
__init__(self)
Connect to weather station and prepare to read data.
current_pos(self)
Get circular buffer location where current data is being written.
dec_ptr(self, ptr)
Get previous circular buffer data pointer.
get_data(self, ptr, unbuffered=False)
Get decoded data from circular buffer.
 
If unbuffered is false then a cached value that was obtained
earlier may be returned.
get_fixed_block(self, keys=[], unbuffered=False)
Get the decoded "fixed block" of setting and min/max data.
 
A subset of the entire block can be selected by keys.
get_lo_fix_block(self)
Get the first 64 bytes of the raw "fixed block".
get_raw_data(self, ptr, unbuffered=False)
Get raw data from circular buffer.
 
If unbuffered is false then a cached value that was obtained
earlier may be returned.
get_raw_fixed_block(self, unbuffered=False)
Get the raw "fixed block" of setting and min/max data.
inc_ptr(self, ptr)
Get next circular buffer data pointer.

Data and other attributes defined here:
fixed_format = {'abs_pressure': (34, 'us', 0.10000000000000001), 'alarm': {'abs_pressure': {'hi': (68, 'us', 0.10000000000000001), 'lo': (70, 'us', 0.10000000000000001)}, 'dewpoint': {'hi': (64, 'ss', 0.10000000000000001), 'lo': (66, 'ss', 0.10000000000000001)}, 'hum_in': {'hi': (48, 'ub', None), 'lo': (49, 'ub', None)}, 'hum_out': {'hi': (54, 'ub', None), 'lo': (55, 'ub', None)}, 'rain': {'day': (85, 'us', 0.29999999999999999), 'hour': (83, 'us', 0.29999999999999999)}, 'rel_pressure': {'hi': (72, 'us', 0.10000000000000001), 'lo': (74, 'us', 0.10000000000000001)}, 'temp_in': {'hi': (50, 'ss', 0.10000000000000001), 'lo': (52, 'ss', 0.10000000000000001)}, 'temp_out': {'hi': (56, 'ss', 0.10000000000000001), 'lo': (58, 'ss', 0.10000000000000001)}, 'time': (87, 'tt', None), 'wind_ave': {'bft': (76, 'ub', None), 'ms': (77, 'ub', 0.10000000000000001)}, ...}, 'current_pos': (30, 'us', None), 'data_count': (27, 'us', None), 'date_time': (43, 'dt', None), 'max': {'abs_pressure': {'date': (201, 'dt', None), 'val': (118, 'us', 0.10000000000000001)}, 'dewpoint': {'date': (191, 'dt', None), 'val': (114, 'ss', 0.10000000000000001)}, 'hum_in': {'date': (141, 'dt', None), 'val': (98, 'ub', None)}, 'hum_out': {'date': (151, 'dt', None), 'val': (100, 'ub', None)}, 'rain': {'day': {'date': (236, 'dt', None), 'val': (132, 'us', 0.29999999999999999)}, 'hour': {'date': (231, 'dt', None), 'val': (130, 'us', 0.29999999999999999)}, 'month': {'date': (246, 'dt', None), 'val': (136, 'us', 0.29999999999999999)}, 'total': {'date': (251, 'dt', None), 'val': (138, 'us', 0.29999999999999999)}, 'week': {'date': (241, 'dt', None), 'val': (134, 'us', 0.29999999999999999)}}, 'rel_pressure': {'date': (211, 'dt', None), 'val': (122, 'us', 0.10000000000000001)}, 'temp_in': {'date': (161, 'dt', None), 'val': (102, 'ss', 0.10000000000000001)}, 'temp_out': {'date': (171, 'dt', None), 'val': (106, 'ss', 0.10000000000000001)}, 'wind_ave': {'date': (221, 'dt', None), 'val': (126, 'us', 0.10000000000000001)}, 'wind_gust': {'date': (226, 'dt', None), 'val': (128, 'us', 0.10000000000000001)}, ...}, 'min': {'abs_pressure': {'date': (206, 'dt', None), 'val': (120, 'us', 0.10000000000000001)}, 'dewpoint': {'date': (196, 'dt', None), 'val': (116, 'ss', 0.10000000000000001)}, 'hum_in': {'date': (146, 'dt', None), 'val': (99, 'ub', None)}, 'hum_out': {'date': (156, 'dt', None), 'val': (101, 'ub', None)}, 'rel_pressure': {'date': (216, 'dt', None), 'val': (124, 'us', 0.10000000000000001)}, 'temp_in': {'date': (166, 'dt', None), 'val': (104, 'ss', 0.10000000000000001)}, 'temp_out': {'date': (176, 'dt', None), 'val': (108, 'ss', 0.10000000000000001)}, 'windchill': {'date': (186, 'dt', None), 'val': (112, 'ss', 0.10000000000000001)}}, 'read_period': (16, 'ub', None), 'rel_pressure': (32, 'us', 0.10000000000000001), 'timezone': (24, 'sb', None)}
lo_fix_format = {'abs_pressure': (34, 'us', 0.10000000000000001), 'current_pos': (30, 'us', None), 'data_count': (27, 'us', None), 'date_time': (43, 'dt', None), 'read_period': (16, 'ub', None), 'rel_pressure': (32, 'us', 0.10000000000000001), 'timezone': (24, 'sb', None)}
reading_format = {'abs_pressure': (7, 'us', 0.10000000000000001), 'delay': (0, 'ub', None), 'hum_in': (1, 'ub', None), 'hum_out': (4, 'ub', None), 'rain': (13, 'us', 0.29999999999999999), 'status': (15, 'pb', None), 'temp_in': (2, 'ss', 0.10000000000000001), 'temp_out': (5, 'ss', 0.10000000000000001), 'wind_ave': (9, 'wa', 0.10000000000000001), 'wind_dir': (12, 'ub', None), ...}

 
Functions
       
apparent_temp(temp, rh, wind)
Compute apparent temperature (real feel), using formula from
http://www.bom.gov.au/info/thermal_stress/
dew_point(temp, hum)
Compute dew point, using formula from
http://en.wikipedia.org/wiki/Dew_point.
findDevice(idVendor, idProduct)
Find a USB device by product and vendor id.
get_wind_dir_text()
Return an array to convert wind direction integer to a string.
pressure_trend_text(trend)
Convert pressure trend to a string, see
http://www.reedsonline.com/weather/weather-terms.htm.
set_translation(trans_function)
Set the localisation translation function to be used by wind_dir_text
and pressure_trend_text.
wind_chill(temp, wind)
Compute wind chill, using formula from
http://en.wikipedia.org/wiki/wind_chill

 
Data
        lost_connection = 64
unknown = 1