====== Bob's Hurricane Wind Speed Logger ====== include "/web/baggerman/wind/libchart/libchart/classes/libchart.php"; // Some constants // -------------- $PLOT_POINTS = 3601; // Get a little data to display // ---------------------------- $sLog = ""; exec("tail -60 logwind.txt", $sLog); $AveSpeedAve = 0; $AveSpeedMax = 0; #print "
\n";
foreach ($sLog as $sLine)
  {
  $asLineParts = explode(" ", $sLine, 3);
  $asSpeeds    = explode(",", $asLineParts[2]);
#  printf("%s %s %s %s\n", $asLineParts[1], $asSpeeds[0], $asSpeeds[1], $asSpeeds[2]);
  $AveSpeedAve += floatval($asSpeeds[2]);
  $AveSpeedMax = max($AveSpeedMax, floatval($asSpeeds[1]));
  }
#print "
\n"; $AveSpeedAve /= 60.0; printf("

%s %s - Current Average Speed %4.1f, gusting to %4.1f MPH

", $asLineParts[0], substr($asLineParts[1],0,8), $AveSpeedAve, $AveSpeedMax); print("
\n"); // Get one hour of data to plot // ---------------------------- $AVE_POINTS = 60; $sLog = ""; exec("tail -3601 logwind.txt", $sLog); $SpeedXYAve = new XYDataSet(); $SpeedXYMax = new XYDataSet(); $iLabelIdx = 0; $iAveIdx = $AVE_POINTS; $AveSpeedAve = 0; $AveSpeedMax = 0; foreach ($sLog as $sLine) { $asLineParts = explode(" ", $sLine, 3); $asSpeeds = explode(",", $asLineParts[2]); $aSpeedTime[] = $asLineParts[0]; if ($iAveIdx == 0) { if ($iLabelIdx == 0) { $sLabel = substr($asLineParts[1], 0, 8); $iLabelIdx = 5; } else { $sLabel = ""; $iLabelIdx--; } $AveSpeedAve /= $AVE_POINTS; $SpeedXYAve->addPoint(new Point($sLabel, $AveSpeedAve)); $SpeedXYMax->addPoint(new Point($sLabel, $AveSpeedMax)); $AveSpeedAve = 0; $AveSpeedMax = 0; $iAveIdx = $AVE_POINTS; } else { $AveSpeedAve += floatval($asSpeeds[2]); $AveSpeedMax = max($AveSpeedMax, floatval($asSpeeds[1])); $iAveIdx--; } } $SpeedXY = new XYSeriesDataSet(); $SpeedXY->addSerie("Average", $SpeedXYAve); $SpeedXY->addSerie("Max", $SpeedXYMax); $SpeedChart = new LineChart(1200,400); #$SpeedChart->getPlot()->getPalette()->seti $SpeedChart->setDataSet($SpeedXY); $SpeedChart->setTitle("Wind Speed for the past 1 hour (MPH)"); $SpeedChart->render("windplot.png"); print "
\n"; // Get 12 hours of data to plot // ---------------------------- $AVE_POINTS = 300; $sLog = ""; exec("tail -43201 logwind.txt", $sLog); $SpeedXYAve = new XYDataSet(); $SpeedXYMax = new XYDataSet(); $iLabelIdx = 0; $iAveIdx = $AVE_POINTS; $AveSpeedAve = 0; $AveSpeedMax = 0; foreach ($sLog as $sLine) { $asLineParts = explode(" ", $sLine, 3); $asSpeeds = explode(",", $asLineParts[2]); $aSpeedTime[] = $asLineParts[0]; if ($iAveIdx == 0) { if ($iLabelIdx == 0) { $sLabel = substr($asLineParts[1], 0, 8); $iLabelIdx = 5; } else { $sLabel = ""; $iLabelIdx--; } $AveSpeedAve /= $AVE_POINTS; $SpeedXYAve->addPoint(new Point($sLabel, $AveSpeedAve)); $SpeedXYMax->addPoint(new Point($sLabel, $AveSpeedMax)); $AveSpeedAve = 0; $AveSpeedMax = 0; $iAveIdx = $AVE_POINTS; } else { $AveSpeedAve += floatval($asSpeeds[2]); $AveSpeedMax = max($AveSpeedMax, floatval($asSpeeds[1])); $iAveIdx--; } } $SpeedXY = new XYSeriesDataSet(); $SpeedXY->addSerie("Average", $SpeedXYAve); $SpeedXY->addSerie("Max", $SpeedXYMax); $SpeedChart = new LineChart(1200,400); #$SpeedChart->getPlot()->getPalette()->seti $SpeedChart->setDataSet($SpeedXY); $SpeedChart->setTitle("Wind Speed for the past 12 hours (MPH)"); $SpeedChart->render("windplot_12hr.png"); print "
\n";
Here are a few pictures of the setup. Click on the picture for a larger version. My only caveats are that my anamometer is not in an ideal spot and the one attempt at calibrating it showed it was reading about 20% low.