WXBrando 1.0.2 (2012-07-05)

Thanks for downloading WXBrando! I hope it will be as useful for you as it has been for me over the many, many years I have run this package. In order to take full advantage of this software, you should be using a Davis Weather Vantage Pro 2 system. For more info, visit their site at If you have the original Vantage Pro, this software SHOULD work, but keep in mind, this has only been fully tested and used on a Vantage Pro 2 sytem.

The Software

There are two main components to this software package. First, we need to get the data out of the weather station console and into a database. This README will not go through the process of setting up a Linux machine, connecting your Davis console up, and grabbing your initial data link from the device. In order to use this software, you should already have that going, and be using VANPROD, something you can pick up via CPAN by Stan Sander (N5KJT).

Setup Your Database

The first thing you need to do is setup your MySQL database. You don't HAVE to use MySQL, this will work fine in any RDBMS provided that you tweak some of the verbiage to match that particular system's naming conventions. Here's what the table looks like:

CREATE TABLE currentobs (
   weather_stamp DATETIME NOT NULL,
   barometer DECIMAL( 4, 2 ),
   out_temp DECIMAL( 3, 1 ),
   avg_wind_speed INT( 3 ),
   wind_speed INT( 3 ),
   comp_dir CHAR( 3 ),
   out_hum INT( 3 ),
   dewpoint DECIMAL( 3, 1 ),
   wind_chill INT( 3 ),
   heat_index INT( 3 ),
   rain_rate DECIMAL( 4, 2 ),
   day_rain DECIMAL( 4, 2 ),
   mon_rain DECIMAL( 4, 2 ),
   year_rain DECIMAL( 4, 2 ),
   sunrise TIME,
   sunset TIME,
   in_temp DECIMAL( 3, 1 ),
   in_hum INT( 3 ),
   in_dewpoint DECIMAL( 3, 1 ),
   trend CHAR( 2 ),
   forecast_icon INT( 3 ),
   forecast_rule INT( 3 ),
   storm_start DATE NOT NULL,
   storm_rain DECIMAL( 4, 2 ),
   rain24 DECIMAL( 4, 2 ),
   rain1 DECIMAL( 4, 2 ),
   con_rate DECIMAL( 4, 2 ),
   PRIMARY KEY ( weather_stamp )

Customizations and Notes

A few things you should be aware of. Once you build this database and make your modifications to vanprod, you will be generating one record per minute while it is running. For comparison, I have over 3.3 million rows in this table--virtually every entry from the first on May 8, 2005. I am not running this on a beefy machine, and most of the queries run in under a second. The main reason is because every query is based on the weather_stamp primary key. The database is indexed and optimized to search on that, and we typically don't pull more than twelve hours of data at any given time.

If vanprod loses contact with the console, or the console loses contact with the actual station, you may get weird data. Specifically, the console rain rate may default to 655.35. If you have this problem often, you can replace the rate to 0.0 if you find 655.35 stored.

Next, depending on where you live, you may want to alter the rain rate that is deposited to the database. Stan originally coded this to take a moving average of sorts to the rain rate such that there would not be these jagged edges and rediculous spikes when downpours happened. I am a storm spotter, and having the actual rain rate sampled for any given minute is important for me to report my findings. Thus, I modified the following line:

unless($sensor_exclude & 32){ $url .= "&rainin=$rate&dailyrainin=$dayrain"; };

unless($sensor_exclude & 32){ $url .= "&rainin=$con_rate&dailyrainin=$dayrain"; };

This line occurs twice in vanprod-2.4 at lines 979 and 1024, and vanprod-2.5 at lines 1008 and 1056.

Building your Data

Now it's time to actually insert the information into the database while vanprod is running! To do this, zoom down to line 2315 in vanprod-2.4 or 2368 in vanprod-2.5. That line preceeds the log record which looks like this:

print DAILY "$hour,$minute,$bar,$outtemp,[.....]

BEFORE that line, create some whitespace and insert the following:

#Brando Hack for Dumping to SQL
   # prepare variables for database entry
   $dbh = DBI->connect("DBI:$db:$db_name","$db_user","$db_password",{
      PrintError => 0,
      RaiseError => 1});
   my $datestr = strftime "%Y-%m-%d", localtime time;
   $sth = $dbh->prepare("insert into currentobs values (\'$datestr
      $indewpt,\'$trend\',$forecasticon,$forecastrule,\'$stormstart\',$stormrain,$rain24,$rain1,$con_rate)"); # note the CON RATE!
}; #end of eval

Now (re)start vanprod and you should be seeing a new row in your database every minute!

The Frontend

Now that the backend is running, it's time to create our front end view. To see this in action, go to It's the same Vantage Pro 2 station I referenced above, but you will notice some flatlines in the graphs every once in a while. This is due to my signal dropping out periodically. I've worked with Davis on this for a while and they have given up. It's 40 feet, line of sight. No reason for the signal to drop!

Anyway... rant aside, that's what the flatlines are.

NOTE!! This was built with an OLD version of jpGraph! I just downloaded the latest and need to make major adjustments to the graphing code!

Before you start running the buildstuff-cli.php file, you must install PHP 5 command line tools as well as the free version of jpgraph ( and ensure both are running correctly. There are dependencies to getting it runinng like ensuring you have the right graphics libraries compiled and ready to go as well as including the right PHP database plugins for your RDBMS. Once that is ready, you can start graphing!

You should edit the include statements at the top of buildstuff-cli.php to make sure that the paths to JPGraph and the included "weatherdesc.php" file are correct, as well as ensure you have entered your database host, username, and password into the fields here. Again, this is designed to run on MySQL, but you can hack it to run on your RDBMS of choice. Then, set up a crontab entry to automatically run either the buildstuff-cli.php file if you are just doing local graphing, or you can run the shell script (after you modify it of course) which will both run buildstuff-cli.php as well as copy the resulting files over to your web host via SCP. Setting up SSH keys is beyond the scope of this document. You need to customize that script as well before execution.

Your crontab entry might look like this:

*/1 * * * * www-data /var/www/weather/

In my case, I run the script every minute.

GD Library

Depending on your configuration, you may run into issues with GD. If you run "buildstuff-cli.php" from the command line and get some funky characters back, chances are you have an issue with jpGraph and it is outputting an error message. You can read the message by piping the output to err.png and opening that image. That command looks like:

buildstuff-cli.php > err.png

One big issue you will run into is an improperly configured GD library—specifically you may be missing the imageantialias() function. If you are running a Debian variant, please click here for instructions on fixing your GD libraries.

The Conclusion

Now, a couple of other customizations that you should be aware of. I built my page so I could get a snapshot of both the weather forecast and the current radar return from the National Weather Service. That code is roughly halfway down. Look for these lines:

$output .= "<center><h3>Current Radar (Base Reflectivity)</h3><a href=\"
rid=FWS&product=NCR&overlay=11101111&loop=yes\"><img src=\"\"
border=0></a><br><font size=\"-2\">(Click on radar to see it in motion)</font>\n";
$output .= "<br><br><h3><a href=\"
&site=fwd&smap=1&marine=0&unit=0&lg=en\">National Weather Service Forecast</a></h3><? include ('forecast.html');?>\n";

This should give you a few clues... for example, why do we generate .php files instead of .html? We need to do includes! If you extract the URLs by themselves and put them in your browser, you will see what we are doing here. If you are a ham operator, go to and drop in your call sign that you are broadcasting from vanprod to the APRS network. Grab that image source for your source here, and then edit the link to go to your local NWS weather page. Then deposit it in the lines above. You will also need to do that in the script that I hacked together inside the $forecast var. Don't forget to add that script into your cron as well:

0 */1 * * * /var/www/WX/

The End

While the files are definitely complete and ready for installation, these instructions may not be. If you run into problems, email me and I'll see if I can assist!