O'Brien Labs

  • Home
  • Portfolio
  • WordPress
    • Plugins
    • WordPress Tips
  • Random Post
  • About

Keyboard Shortcuts

R - Load a random post.
? - Open this dialog window.
O'Brien Labs > Code Snippets > Receiving data from a Weather Station Keyboard Shortcuts

Receiving data from a Weather Station

January 18, 2016 by

Share this post:

This file receives the data from the Ambient Weather WS-1200-IP ObserverIP and sends the data to wunderground, as well as to weewx.

For more details, read the blog write up here: http://obrienlabs.net/redirecting-weather-station-data-from-observerip/

<?php // Parse the wunderground packets sent from the ObserverIP // Pat O'Brien, 1/14/2016 // The ObserverIP does not provide heat index data in its packet, this will calculate it // Formula from NOAA http://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml function heatindex($T, $RH) { $HI = -42.379 + 2.04901523*$T + 10.14333127*$RH - .22475541*$T*$RH - .00683783*$T*$T - .05481717*$RH*$RH + .00122874*$T*$T*$RH + .00085282*$T*$RH*$RH - .00000199*$T*$T*$RH*$RH; return round( $HI, 1 ); } // Make sure the ID and PASSWORD fields match what we think it should match. If it does, this update is valid and continue. if ( ($_GET["ID"] == "YOUR_WUNDERGROUND_USERNAME") && ($_GET["PASSWORD"] == "YOUR_WUNDERGROUND_PASSWORD") ) { //============================================// // Auto send data query right to wunderground // //============================================// $wunderground = file_get_contents("http://rtupdate.wunderground.com/weatherstation/updateweatherstation.php?" . $_SERVER['QUERY_STRING']); echo $wunderground; //==============================================// // Write data to ncat socket for use with weewx // //==============================================// $heatindex = heatindex($_GET['tempf'], $_GET['humidity']); $socket = "outTemp=".$_GET['tempf'].","; $socket .= "outHumidity=".$_GET['humidity'].","; $socket .= "dewpoint=".$_GET['dewptf'].","; $socket .= "windchill=".$_GET['windchillf'].","; //$socket .= "heatindex=".$heatindex.","; // Enable heat index if you need it. WeeWx and other systems will provide this for you. $socket .= "windDir=".$_GET['winddir'].","; $socket .= "windSpeed=".$_GET['windspeedmph'].","; $socket .= "windGust=".$_GET['windgustmph'].","; //$socket .= "rain=".$_GET['rainin'].","; // This is really rain rate $socket .= "dailyrain=".$_GET['dailyrainin'].","; $socket .= "radiation=".$_GET['solarradiation'].","; $socket .= "UV=".$_GET['UV'].","; $socket .= "inTemp=".$_GET['indoortempf'].","; $socket .= "inHumidity=".$_GET['indoorhumidity'].","; $socket .= "barometer=".$_GET['baromin'].","; $socket .= "epoch=".time().","; $socket .= "txBatteryStatus=".$_GET['lowbatt']; // Last item, no comma $socket .= PHP_EOL; // Send data to the socket middle man for weewx to archive $fp = fsockopen("localhost", 2999); if ($fp) { fwrite($fp, $socket); fclose ($fp); } } else { header('HTTP/1.0 401 Unauthorized'); echo 'failure'; die(); } ?>
updateweatherstation.php
view raw
Share this post:

About Pat

I'm a sysadmin, WordPress Core Contributor, plugin & theme developer. I've also developed a few non-WordPress websites. I'm a technologist at heart. I enjoy tinkering on many projects. Here on my site you will find some of the projects I've worked on. Whether it's the WordPress plugins I've made, some WordPress tips, various tech tips, or even a couple Halloween props.

View all posts by Pat

About

The purpose of this site is for me to share my DIY technical experiences as a place to document them publicly. Hopefully somewhere along the way they are helpful for you.

Recent Posts

  • Nest Thermostat Push Notifications
  • mailx – Send automated Linux email with gmail
  • simplemonitor – who watches the Nagios watchman?
  • Raspberry Pi and Nagios for reliable low cost monitoring
  • Using Nagios to monitor your power outlets

Tags

ad adblock amp Asterisk AutoHotKey battery block Camera car code codesnips database developer Emergency halloween Heat Home Inverter Linux load Nagios night plugins portfolio Power Project Raspberry Pi simplemonitor snippets Tech Tips Timelapse tips Tutorial ublock vision Weather Station webcam website WordPress

Copyright © 2010–2018 O'Brien Labs – All Rights Reserved – Use without permission is illegal.

Please support this website by adding us to your whitelist in your ad blocker. Ads are what helps us bring you premium content! Thank you!