Welcome to the Weather Machine, by Ed T. Toton III. Contact info: necrobones@necronbones.com bones@necrobones.com http://www.necrobones.com/ http://www.necrobones.net/ As of this release, my weather station can be viewed at: http://banshee.necrobones.net/weather.shtml This set of programs is being distributed for free. Do what you want with it. Please show credit where credit is due. INTRODUCTION The Weather Machine is a perl script that is designed to read and log weather data via a serial port from a WMR-968 Oregon Scientific weather station. These can be purchased from a variety of locations on the net, including eBay. Log data is stored in flat files, and a one-line status file is written to every minute as well for current "real time" information. Two additional scripts are also included for accessing this data. The first is weatheroutput.pl, which takes command-line arguments to choose which numbers to display. This is particularly useful for use with MRTG, as that is what it was designed for (example MRTG configs are given below. For those who don't know, MRTG is a really nice free graphing package). The other script, weathertable.pl, generates an HTML table that can be used as a server-side include. Future versions may include CGI scripts to display historical data from the logs, but for now the logs are merely stored with no retrieval method included. Yes, not all of the design here is terribly robust or pretty, but it works, and that was the only design goal. :) Feel free to modify it for your particular needs. REQUIREMENTS A PC running linux, with perl 5, and the following perl modules: Device::SerialPort LWP::UserAgent HTTP::Request If you don't have them, you can always use cpan to obtain them, such as like this (executed as root): perl -MCPAN -e shell install Device::SerialPort install LWP::UserAgent install HTTP::Request INSTALLATION 1. Pick a directory, and put these files there. I use /www/weather, where /www is a symlink to my htdocs directory. It doesn't matter what you choose, as long as you edit the paths assigned at the top of all of the scripts accordingly. 2. Open up each *.pl script and edit the paths accordingly. :) While you're in there, make sure weathermachine.pl has the correct serial device for your weather station. If you want it to send updates to The Weather Underground for you in real time, first set up an account at www.wunderground.com, and edit the username and password in the script accordingly. Also make sure the log path puts the logs where you want them, and that the other scripts are adjusted to the same location, if you choose to use them. 3. Put a line in your rc.local or other startup script to make sure it starts up at boot, and give it a manual run to make sure it's all working. Here's the invocation I use in rc.local: /www/weather/weathermachine.pl You'll notice there are no arguments. All configuration is done at the top of the script itself. 4. You may wish to add a cron-task to ensure it keeps running, just in case it terminates or gets killed for some reason. Here's what I use, along with a line to tar up backups of the data: # Check to make sure weathermachine keeps running */10 * * * * cd /www/weather ; ./weathermachine.pl > /dev/null & 15 1 * * * cd /www/weather ; sleep 30 ; tar cvfz weather-backup.tar.gz * > /dev/null The weathermachine will not run twice, assuming it's program-name variable is set correctly. :) 5. If you wish to use weathertable.pl, put it (or symlink it) somewhere where it can be executed by apache as a server-side include, like this: 6. Enjoy! MRTG GRAPHS MRTG (or "Multi Router Traffic Grapher") is a nice graphing engine that can be used for a variety of purposes. For information on how to obtain/install it, please visit it's official site: http://people.ee.ethz.ch/~oetiker/webtools/mrtg/ While primarily intended to graph SNMP data, it can also be used to graph locally available real-time data. This is where the script called weatheroutput.pl comes in. In the weathermachine log directory you set up, there will be a status file called 'weathermachine.status' which is overwritten once per minute by the weathermachine.pl daemon. Thus, polling this file could be treated as real-time weather information, accurate to within a minute. Below are the /etc/mrtg.cfg configs that I use. Obviously you will need to edit them to suit your purposes. weatheroutput.pl is a script that outputs numbers that are drawn from the realtime status created by weathermachine.pl. The command line arguments tell it what to output, and it understands some extremely rudimentary math on the command-line. Here are the configs: Target[outdoortemp]: `/www/weather/weatheroutput.pl otf odf` Options[outdoortemp]: nopercent,growright,gauge,noinfo,withzeroes Title[outdoortemp]: Outdoor Temperature and Dew Point PageTop[outdoortemp]: