Weather

From Stu2
Jump to navigation Jump to search

Here is my local WX page: https://www.stu2.net/wx

Another station I run in Corbin, VA:


Summary

Going for a minimalist approach, I wanted to design something that could be displayed on the wall in a 15" (or less) monitor. The idea is to generate something similar to the 'Weather Picture' from Peet Brothers.

Here are the components I combined to get my web page:

  • Linux computers w/apache, serial ports, etc.
  • Peet Brother's Ultimeter 2000
  • http://webaugur.com/wares/ultimeter.html - scripts to produce the data files
  • SOCAT - to remote the serial port. (The Ultimeter connects to a different computer than my web server and scripts.)
  • http://www.maani.us/gauge/ - Flash gauges that can be dynamically changed.
  • Graphic Artist - Tim produced the dials and graphics
  • Digital Camera - to photograph wood from my coffee table
  • http://cleardarksky.com/c/StffrdVAkey.html - clear sky clock widget, best visual for understanding upcoming WX

SkyWARN

Details

SOCAT - Remote Serial Port

Here's the SOCAT command on the remote side:

socat tcp-l:2525,reuseaddr,fork /dev/ttyS0,raw,b2400,echo=0,ocrnl=1

Here's the remote command on the local side:

socat PTY,link=/home/wx/dev/vs0,raw,echo=0 tcp4:IP_ADDRESS:PORT

Note, I had to create the PTY device, /dev/vs0. I'm sure there's a cleaner way. I'll find it some day. Bottom line, this creates a pseudo TTY device that is connected via TCP to the remote end's COM1 port.

Ultimeter Scripts

The scripts read the ultimeter string and produce two files; u2000.dat and u2000.log. The log file keeps the history. The .dat file exposes values for all the current readings from the Ultimeter. The PHP scripts parse the file, looking for the right string, grabs the value and then provides it to the XML configuration for the gauge.

Here's a part of the u2000.dat file:

LowWindChillYesterdayTime: 11:46
OutdoorHumidity: 38.8
OutdoorTemp: 35.5
RainTotal: 0.00
RainTotalDate: 01/01/2008
RainTotalToday: 0.00
RainTotalYesterday: 0.00
Time: 10:27
WDCF: 0
WindChill: 35.5
WindDirection: 293
WindPeakDirection5Min: 0
WindPeakSpeed5Min: 0.0
WindSpeed: 0.0

Flash - the Gauges

I used gauge.swf and a php file for each dial. The wx scripts pull the data from the Ultimeter every second. All of the current values are exposed in a single file. The php file parses the data and creates the proper configuration file for the gauge. The php file includes the 'update' tag, so gauge needle updates automatically without refreshing the web page. Very cool.

Here is the php script for the temp gauge. The other files are similar. Essentially, php is used to create the dynamic values and stick them into an XML file. The only semi-tricky part was deriving the formulas for the needles.

<?php
$h = 65.0;
$fd = fopen("/usr/local/weather/log/u2000.dat", "r") or die;

while (!feof($fd)) {
	$line = fgets($fd,1024);
	if ( ereg('^OutdoorTemp:', $line)) {
		$temp = substr($line, 13);
	}
	if ( ereg('^OutdoorHumidity:', $line)) {
		$humid = substr($line, 17);
	}
}

$temp_str = strtok($temp,".") . " F";
$theta = ((180 / 109) * ($temp + 14))/ 57.2978;
$x2= ($h * -cos($theta)) + 103.0;
$y2= ($h * -sin($theta)) + 103.0;

?>

<gauge>
	<image url='./temperature.jpg'
	       />
	<line x1='103'
			y1='103'
			x2='<?php echo $x2 ?>'
			y2='<?php echo $y2 ?>'
			thickness='2'
			/>
	<text x='82'
			y='140'
			width='50'
			height='20'
			align='center'
			size='14'
			><?php echo "$temp_str" ?></text>
	<update url='temp.php?microtime=<?php echo microtime() ?>'
			delay='60'
			delay_type='1'
			/>	

</guage>

Other Software

I looked at several other packages. Since I wanted to use Linux and had a Peet Brothers WX station, I was stuck with "Weather Display" (http://www.weather-display.com/index.php) This package is very extensive and is derived from the Windows version. However, the GUI is horrible and frustrating to use. This led me to look for an alternative. (u2000 scripts.)

At our Corbin, VA station, we have a Davis Vantage Pro and I used wview, (http://www.wviewweather.com/) which is excellent. I was able to use a small dedicated Linux computer to retrieve the data files from the Davis WX station, produce the reports and move them to a web server. The data is fed to the CWOP program. (DW1705) However, it doesn't support Peet Brothers. (drat!)

Here's the WX station in Corbin: http://thor.corbin.bia.edu/wx/ - Corbin Weather Page

Resources

http://www.ofcm.gov/fmh11/fmh11B.htm - Manuals