WU-UPLOAD.PL.TXT(1) User Contributed Perl Documentation WU-UPLOAD.PL.TXT(1) wwuu--uuppllooaadd..ppll:: WWeeaatthheerr UUnnddeerrggrroouunndd PPeerrssoonnaall WWeeaatthheerr SSttaattiioonn UUppllooaadd SSccrriipptt FFoorr LLaaccrroossssee WWSS2233xxxx wweeaatthheerr ssttaattiioonnss oovveerr sseerriiaall ddeevviiccee This script communications over a serial connection to a compatible LaCrosse Weather Station device, then formats that information and reports it to Weather Underground's ( http://www.wunderground.com ) Personal Weather Station data collection service. This script takes 5-10 seconds to run, most of that time is to obtain the response from serial port connected LaCrosse weather station. You can run this script as a Unix cron command once per minute. If you are using a wireless connection from the LaCrosse base station to the out- side devices, the base station will report 'weird' data when the wire- less connection is unstable, recent additions will prevent uploading of the inappropriate data. The perl/c + modules installed on FC7 x86 w/ standard development libraries, tested on usb-serial connection, as well as on Mac OS X 10.4 & 10.5 using the standard Perl install pulling the modules in via CPAN with the weather station connected over a KeySpan serial-to-USB con- verter. UUnniixx CCrroonn sseett--uupp Example cron entries to fire off uploads (expects this script installed in /usr/local/bin) with these scripts installed as a Unix service. They could also be installed under a user's cron with files located in a home directory, etc. _E_v_e_r_y _m_i_n_u_t_e_: * * * * * /usr/local/bin/wu-upload.pl >> /var/log/wu-cron.log _E_v_e_r_y _5 _m_i_n_u_t_e_s_: 0,5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/local/bin/wu-upload.pl >> /var/log/wu-log.log CCoonnttrrooll VVaarriiaabblleess _E_d_i_t _t_h_e _f_o_l_l_o_w_i_n_g _v_a_r_i_a_b_l_e_s _f_o_r _t_e_s_t_i_n_g_: nnoosseenndd - set to 1 to NOT send data (testing), normally to 0 to send data. vveerrbboossee - set to 1 to send more information to standard out _E_d_i_t _t_h_e _f_o_l_l_o_w_i_n_g _v_a_r_i_a_b_l_e_s _f_o_r _y_o_u_r _c_o_n_n_e_c_t_i_o_n _t_o _W_e_a_t_h_e_r _U_n_d_e_r_- _g_r_o_u_n_d_: rrttuurrll - Weather Underground URL for real-time updates iidd - Weather Underground Personal Weather Station Identification String ppaasssswwdd - Weather Underground Password for PWS ( _N_O_T_E_: this is sent over HTTP as clear text) ffrreeqq - Frequency of updates to Weather Underground [in seconds] _E_d_i_t _t_h_e _f_o_l_l_o_w_i_n_g _v_a_r_i_a_b_l_e_s _f_o_r _f_i_l_e_s _o_r _d_e_v_i_c_e_s _o_n _y_o_u_r _c_o_m_p_u_t_e_r_: sseerriiaall - path to the serial port device xxmmllLLoogg - Path to XML encoded output '/var/log/wu.log'; DDaattaa VVaalliiddaattiioonn ffoorr WWiirreelleessss ccoonnnneeccttiioonnss The La Crosse 2317 Weather Station Pro has the capability of connecting to the outdoor instruments via a wireless connection, advertised as working up to 330 feet, however in my experience it can be dodgy at distances far less than the advertised maximum. When this wireless connection is not functioning this program receives bogus data from the base station over the serial line as there is no valid data from the outside instruments. The following have been observed from the La Crosse 2317 base station under these conditions: tteemmppFF==''--2222..00'' ddeewwPPttFF==''--2222..00'' hhuummiiddiittyy==''AAAA'' or/and wwiinnddssppeeeeddmmpphh==''111144..11'' wwiinnddCChhiillll==''--2222..00'' I adding checking for those conditions as well as bounds checking checking for other values, either based on accepted values or extremes. In the event that the data is determined to be invalid, the parameter will not be reported to Weather Underground, however it will be logged, as will the detection of it being incorrect. BBoouunnddss wwiinndd ssppeeeedd positive number values except 114.1 wwiinndd ddiirreeccttiioonn positive number values from 0 to 360 degrees, inclu- sive hhuummiiddiittyy positive number values from 0 to 100 percent, inclusive tteemmppeerraattuurree and ddeeww ppooiinntt report if humidity is valid and these do not both equal -22F ddeeww ppooiinntt should not exceed the current temperature bbaarroommeetteerr allow values from 25-35 inHg, inclusive rraaiinn ffaallll ppeerr hhoouurr allow values from 0 to 10"/hour inclusive (maximum recorded for my area is far less) BBoouunnddss may be edited by altering the following variables: $$bbaarroommeetteerr-- MMiinniimmuumm,, $$bbaarroommeetteerrMMAAXXIIMMUUMM,, $$bboogguussTTeemmppFF,, $$bboogguussDDeeppPPttFF,, $$bboogguussWWiinndd-- SSppeeeeddmmpphh _F_o_r_e_c_a_s_t Forecast is modified for conditions and time of day. From 'Sunny' to 'Clear' from 1800 to 0600 hours. From 'Rainy' to 'Snowy' below 30F, from 'Rainy' to 'Slushy' between 30F and 34F. WWeeaatthheerr UUnnddeerrggrroouunndd PPeerrssoonnaall WWeeaatthheerr SSttaattiioonn DDaattaa ccoolllleeccttiioonn Here is the preferred URL used for the real-time uploading of your col- lected weather data to Weather Underground (July 2008): _h_t_t_p_:_/_/_r_t_u_p_d_a_t_e_._w_u_n_d_e_r_g_r_o_u_n_d_._c_o_m_/_w_e_a_t_h_e_r_s_t_a_t_i_o_n_/_u_p_d_a_t_e_w_e_a_t_h_e_r_s_t_a_- _t_i_o_n_._p_h_p If you go here without parameters you will get a brief usage): Here is the usage (July 2008) displayed with blank parameters: RRaappiiddFFiirree SSeerrvveerr uussaaggee aaccttiioonn [aaccttiioonn==uuppddaatteerraaww] IIDD [ID as registered by wunderground.com] PPAASSSSWWOORRDD [PASSWORD registered with this ID] ddaatteeuuttcc - [YYYY-MM-DD HH:MM:SS (mysql format)] wwiinnddddiirr - [0-360] wwiinnddssppeeeeddmmpphh - [mph] wwiinnddgguussttmmpphh - [windgust mph] hhuummiiddiittyy - [%] tteemmppff - [temperature F] rraaiinniinn - [rain in] ddaaiillyyrraaiinniinn - [daily rain in accumulated] bbaarroommiinn - [barom in] ddeewwppttff - [dewpoint F] wweeaatthheerr - [text] -- metar style (+RA) cclloouuddss - [text] -- SKC, FEW, SCT, BKN, OVC ssooffttwwaarreettyyppee - [text] ie: vws or weatherdisplay CCrreeddiittss _C_o_p_y_r_i_g_h_t GPL - original code K Brown 11/30/07 _C_o_n_t_r_i_b_u_t_e_d _b_y Kenneth Brown 12/2007 _U_p_d_a_t_e_d Bill Caloccia 20/07/2008, 2/1/2009 _D_e_v_i_c_e_:_:_L_a_C_r_o_s_s_e_:_:_W_S_2_3_x_x Library by 2007 by Eduardo Santiago DDeevviiccee::::LLaaCCrroossssee::::WWSS2233xxxx vveerrssiioonn 00..0066 Device::LaCrosse::WS23xx provides a simple interface for reading data from La Crosse Technology WS-2300 series weather stations. It is based on the Open2300 project, but differs in several respects DDeevviiccee::::LLaaCCrroossssee::::WWSS2233xxxx get($;$) func param 1 wind_unit LCD_contrast FFoorreeccaasstt TTeennddeennccyy IInnddoooorr__TTeemmppeerraattuurree C Min_Indoor_Temperature C Max_Indoor_Temperature C Min_Indoor_Temperature_datetime time_t Max_Indoor_Temperature_datetime time_t Low_Alarm_Indoor_Temperature C High_Alarm_Indoor_Temperature C OOuuttddoooorr__TTeemmppeerraattuurree C Min_Outdoor_Temperature C Max_Outdoor_Temperature C Min_Outdoor_Temperature_datetime time_t Max_Outdoor_Temperature_datetime time_t Low_Alarm_Outdoor_Temperature C High_Alarm_Outdoor_Temperature C Windchill C Min_Windchill C Max_Windchill C Min_Windchill_datetime time_t Max_Windchill_datetime time_t Low_Alarm_Windchill C High_Alarm_Windchill C DDeewwppooiinntt C Min_Dewpoint C Max_Dewpoint C Min_Dewpoint_datetime time_t Max_Dewpoint_datetime time_t Low_Alarm_Dewpoint C High_Alarm_Dewpoint C IInnddoooorr__HHuummiiddiittyy % Min_Indoor_Humidity % Max_Indoor_Humidity % Min_Indoor_Humidity_datetime time_t Max_Indoor_Humidity_datetime time_t Low_Alarm_Indoor_Humidity % High_Alarm_Indoor_Humidity % OOuuttddoooorr__HHuummiiddiittyy % Min_Outdoor_Humidity % Max_Outdoor_Humidity % Min_Outdoor_Humidity_datetime time_t Max_Outdoor_Humidity_datetime time_t Low_Alarm_Outdoor_Humidity % High_Alarm_Outdoor_Humidity % Rain_24hour mm Max_Rain_24hour mm Max_Rain_24hour_datetime time_t RRaaiinn__11hhoouurr mm Max_Rain_1hour mm Max_Rain_1hour_datetime time_t Rain_Total mm Rain_Total_datetime time_t Min__wind m/s Max__wind m/s Min_Date/Time_wind_datetime time_t Max_Date/Time_wind_datetime time_t WWiinndd__SSppeeeedd m/s WWiinndd__DDiirreeccttiioonn degrees Low_wind_alarm_setting m/s High_wind_alarm_setting m/s Connection_Type Countdown_time_to_next_datBinary seconds Absolute_Pressure hPa Relative_Pressure hPa Pressure_Correction hPa Min_Absolute_Pressure hPa Min_Relative_Pressure hPa Max_Absolute_Pressure hPa Max_Relative_Pressure hPa Min_Pressure_datetime time_t Max_Pressure_datetime time_t Low_Alarm_Pressure hPa High_Alarm_Pressure hPa History_saving_interval minutes Countdown_to_next_saving minutes Date/Time_last_record_datetime time_t Pointer_to_last_written_Record Number_of_Records Only a few reasonable UNIT conversions are available get($;$) function param 2: From To ---- -- C F hPa inHh, mmHg m/s kph, mph, kt mm in DDeevviiccee::::LLaaCCrroossssee::::WWSS2233xxxx LLiibbrraarryy CCrreeddiittss Copyright (C) 2007 by Eduardo Santiago This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available. perl v5.8.6 2009-02-03 WU-UPLOAD.PL.TXT(1)