NAME

vanprod - Perl daemon to communicate with a Davis Vantage Pro weather station.


SYNOPSIS

vanprod [ -tdn ]


DESCRIPTION

-t Test mode. vanprod will not become a daemon. It will test for correct communication with the weather station, print the results on stdout and exit.

-d Debug mode. This is intended only for short term diagnosis of problems you may be having. vanprod will become a daemon, but it will be EXTREMELY chatty in writing information into the syslog at the debug priority.

-n No database updates. vanprod will not try to load the DBI module or make any updates to a database. Text files as described below are not affected by this option.

Local Configuration Options

There is a section near the beginning of the daemon source where you will need to set several variables to suit your needs. Currently there are no command line overrides for these settings. Perhaps in a future release this will be changed.

my $tty = ``/dev/ttyS1''; This is the serial port where your weather station is connected.

my $facility = ``local0''; This is the syslog facility that the daemon will use for messages. Make sure that what you put here is configured in your syslog.conf file.

my $name = ``vanprod''; I put that in just in case you didn't like the name I picked for the daemon. This name is associated with every syslog message the daemon generates as well as every update to weather underground if you use that feature. It is also used for the pid file. (See below)

my $directory = ``/some/path/to/weather''; This is the directory where the daemon will write the output files it generates. Details on these files and their contents are described below.

my $piddir = ``/var/run''; This is the directory where the daemon will write a file containing it's pid. The name of the file is $name.pid.

my $num_updates = 12; This is the number of times per hour to post updates to weather underground. The default setting is every 5 minutes. For every 10 minutes set this to 6, for every 15 set it to 4, etc. If you set this to anything less than 0 or greater than 30 it will revert to the default of 12. If you do not want to update weather underground at all set this to 0.

my $wu_id = ``MY_STATION''; Set this to your station id assigned to you by weather underground.

my $wu_password = ``mypassword''; Set this to your weather underground password.

my $oldobs = 7; How many days old a dailyobs file should be to be deleted when a new day is started. Details on what this file contains are below. Note that this value will only be used when the daemon is running at midnight and starting a new day as part of it's own internal processes. If you would like to keep these files forever, you can set this to -1. The dailyobs file is typically between 60 and 65 KB for a 24 hour period.

my $db = ``mysql''; Type of database you want to use to store your daily extremes. The daemon will store the minimum and maximum values and the time they occurred in the database.

my $db_name = ``weather''; The name of the database to use.

my $db_user = ``stan''; Name of database user that can add records to the database you specified on the previous line.

my $db_password = ``mypassword''; Password for the database user described above.

my $db_table = ``reports''; Name of database table that contains the values we track and store. The table should have the following structure:

        +-----------------+--------------+
        | Field           | Type         |
        +-----------------+--------------+
        | date            | date         |
        | hi_temp         | int(3)       |
        | hi_temp_time    | time         |
        | lo_temp         | int(3)       |
        | lo_temp_time    | time         |
        | peak_wind       | int(3)       |
        | peak_direct     | char(3)      |
        | peak_time       | time         |
        | min_wind_chill  | int(3)       |
        | wind_chill_time | time         |
        | year_rain       | decimal(4,2) |
        | max_rain_rate   | decimal(4,2) |
        | max_rate_time   | time         |
        | max_barometer   | decimal(4,2) |
        | max_press_time  | time         |
        | min_barometer   | decimal(4,2) |
        | min_press_time  | time         |
        | max_humid       | int(3)       |
        | max_humid_time  | time         |
        | min_humid       | int(3)       |
        | min_humid_time  | time         |
        | max_dew         | int(3)       |
        | max_dew_time    | time         |
        | min_dew         | int(3)       |
        | min_dew_time    | time         |
        | max_heat_index  | int(3)       |
        | heat_index_time | time         |
        | daily_rain      | decimal(4,2) |
        +-----------------+--------------+

The routine that uploads this information to the database currently uses an sql insert command, so the ordering of the fields is important.

Baud Rates

The factory default baud rate for the Vantage Pro weather station is 19200. If you really need to use a different setting, you may change it in the Davis module source file, Davis.xs.

Signals

INT or TERM will cause the daemon to exit gracefully.

HUP Will cause the daemon to re-read the values from the extremes file. This is helpful in case something gets wacky and you need to correct the value of the variable while the daemon is running.

Operational Characteristics

Whenever possible the daemon collects the data provided by the weather station. Some values like wind chill, heat index, and dewpoint are not provided and the daemon calculates these for you. The daemon also checks the crc values on each packet received from the weather station, and if an error is detected, a notice level message is sent to the syslog and the packet is not processed. In the case of wind direction, it takes the degree reading from the weather station and translates it into a more human friendly form that will be written into the database and the current and extremes files. Examples: NE instead of 45 degrees, ESE instead of 105 degrees, etc. Also for weather underground updates and for the daily obs file, it calculates the average direction for the wind from the last 300 samples read from the station. The gust that is reported to the weather underground is the highest wind speed observed since the previous weather underground report. The average wind speed is used as the basis for calculating the wind chill.

The daemon will fork a child process to post the updates to weather underground and perform the database updates. If the fork calls fail, the daemon will still perform these functions, just in a single threaded manner.

At this time the daemon only records outdoor values. Indoor readings as well as UV, leaf and soil moisture and evapotranspiration are ignored.

The daemon will generate 3 files in the directory that you specify in the Local Configuration section. These files are intended for use by other scripts or programs as opposed to being human readable even though they are plain text files. This way tasks such as graphing or supplying information to a web page can be done indepedently of the daemon. A brief description of each file's name, and contents follows.

extremes.mm.dd.yyyy This file contains the minimum and maximum values observed for a day. The daemon always begins a new day at midnight. This file always contains a single line of comma seperated values in this order: minimum barometer and the time of observation, maximum barometer and the time of observation, minimum outdoor temp and time, maximum outdoor temp and time, maximum wind speed, direction and time, minimum outdoor humidity and time, maximum outdoor humidity and time, minimum outdoor dewpoint and time, maximum outdoor dewpoint and time, minimum wind chill and time, maximum heat index and time, maximum rainfall rate and time, and the daily rainfall and year to date rainfall totals.

currentobs.mm.dd.yyyy This file contains the following values from the most recent sample read from the station. The values are on a single line and comma seperated in the order listed: Hour of the day, minute, and second, barometer reading, outdoor temp, average wind speed, current wind speed, direction, outdoor humidity, outdoor dewpoint, wind chill, heat index, rainfall rate, daily rain, month to date rain, year to date rain, sunrise, sunset.

dailyobs.mm.dd.yyyy This file is appended to once per minute and contains the then current observations for that minute on a single line. The values are comma seperated and in the following order: hour, minute, barometer, outdoor temp, average wind speed, wind gust for the previous 60 seconds, the average direction, outdoor humidity, outdoor dewpoint, wind chill and heat index.


EXAMPLES

Here are some examples of the contents of the files output by the daemon:

extremes.mm.dd.yy

29.61,00:00:06,29.89,12:15:35,47.9,07:25:58,68.1,13:43:07,21,ESE,11:06:36,43,14:13:55,95,07:55:36,44.3,14:14:38,53.8,10:39:08,47.9,07:25:58,68.1,13:43:07,0.08,00:04:42,0.02,6.36

currentobs.mm.dd.yyyy

14,42,4,29.86,67.9,9,7,ESE,44,45.2,67.9,67.9,0.00,0.02,1.14,6.36,07:07,18:35

dailyobs.mm.dd.yyyy

14,33,29.86,67.9,10,12,128,43,44.6,67.9,67.9
14,34,29.86,67.9,10,12,130,43,44.6,67.9,67.9
14,35,29.86,68.1,10,11,131,44,45.4,68.1,68.1
14,36,29.86,68.3,10,12,132,43,45.0,68.3,68.3
14,37,29.86,68.1,10,17,132,43,44.8,68.1,68.1
14,38,29.86,67.9,10,14,133,44,45.2,67.9,67.9
14,39,29.86,67.9,10,14,134,43,44.6,67.9,67.9
14,40,29.86,67.8,10,13,132,45,45.7,67.8,67.8
14,41,29.86,67.8,10,12,129,44,45.1,67.8,67.8
14,42,29.86,67.9,9,14,125,44,45.2,67.9,67.9


BUGS AND LIMITATIONS

I'm not aware of any bugs, but there are some limitations. The weather underground updates are currently limited to no more than once every 2 minutes. All of the indoor values and the values for sensors that are not on my station as well as all of the alarms are currently ignored. Feel free to send me your requests for what you would like to see added or changed. My e-mail address is stsander@earthlink.net. Even if you don't have any specific requests, I'd love to hear from you just to let me know that you have decided to use this daemon.

Now for some PAUSE stuff.


README

This daemon is written to communicate with a Davis Vantage Pro Weather Staion. The daemon is capable of updating weather underground and a database. The daemon will generate 3 comma seperated text files as it operates. These files are intended for use by other scripts. Details on them are contained elsewhere in the documentation. The daemon will store the daily extreme values and their time of occurance in a database, and update the weather underground at a user configurable interval between once per hour and every 2 minutes.

Example of installation:

        cp vanprod-$VERSION /usr/local/sbin/vanprod
        pod2man /usr/local/sbin/vanprod /usr/local/man/man1/vanprod.1

Create a script to start the daemon for you at boot, and you should be all set.


PREREQUISITES

The daemon requires the following at a minimum in order to run:

Device::Davis
Getopt::Std
Sys::Syslog
POSIX
Date::Calc
Date::Manip


COREQUISITES

LWP for weather underground updates and DBI for database updates.

any Unix or Linux variant

Networking Web


SEE ALSO

perl(1) perlfunc(1) Device::Davis(3) POSIX(3) LWP(3) DBI(3) Date::Manip(1) Date::Calc(3) Getopt::Std(3) Sys::Syslog(3) syslog.conf(5) http://www.mysql.com/doc/


COPYRIGHT AND LICENSE

Copyright 2003 by Stan Sander. stsander@earthlink.net You are welcome to send me any requests for new features or enhancements. If you find any bugs, I'd *REALLY* like to know about those!!

Vanprod is free software. You may redistribute it and/or modify it under the same terms as Perl itself.