Does anyone know of a php script to upload WD data to wunderground?
thanks
Does anyone know of a php script to upload WD data to wunderground?
thanks
I suppose I must have missed something BUT…
If you are running WD then you have the ability to upload data directly to WU using WD itself, either static timed uploads or Rapid Fire Real time uploads?
-Bob
Yes I know, for whatever reason wu uploads and wow uploads don’t get out of my schools network:
I have a wow php script so a wu would be top.
Ahh said the blind man
I understand now… I have not come across one myself, would be nice if there was a PHP script that could take data from Clientraw and feed it to WU for a situation such as this…
-Bob
indeed.
it is possible as that’s pretty much what WD does … ftp data to wu.
perhaps Brian may be able to help in part.
Mike Challis www.642weather.com has a .php webcam upload to WU.
BTW it’s not FTP see Local Weather Forecast, News and Conditions | Weather Underground
great thanks that’s really useful.
I did find one for metoffice wow upload.
see post 43 at www.weather-watch.com/smf/index.php/topic,52843.30.html
I may be able to adjust it bearing that in mind…?
or more simply use mike’s script as suggested and tweak it so it gets data from clientraw.
With the luxury of knowing I’m not going to be the one doing it, I would say that it doesn’t appear to be a big deal to read (explode) the clientraw and assemble the string for the GET.
no idea precisely what that means but I will simply use the two as templates and fudge through… but that’s probably what you said too!
BINGO! Done it and got it running.
does this need making into a sticky?!!
credit to the original which i just tweaked for WU
// Met Office Weather Observations Website Upload Script
// Created by Andrew Jones
// www.bordersweather.co.uk
<?php // WU upload script adapted and edited by Martin Sutton @meschoolweather // http://www.school-portal.co.uk/GroupHomepage.asp?GroupID=910590 // but adapted from and originally written by // Met Office Weather Observations Website Upload Script // Created by Andrew Jones // www.bordersweather.co.uk//ini_set(“display_errors”,1);
//error_reporting(E_ALL);
date_default_timezone_set(“Europe/London”);
//CONFIGURABLE SECTION
$cumulus = 0; //set to 1 if use use cumulus, 0 otherwise.
$wd = 1; //set to 1 if you use weather display, 0 otherwise.
$datafile = “clientraw.txt”; //change to your own route to data
$softwaretype = “WeatherDisplay”; //change to your software$siteid = “XXXXXXXXX”; //set to the site id on the WU site
$authenticationpin = “XXXXXXXX”; //set to the pin you set up
$useCURL = 1; //change to 1 if fopen doesn’t work.
//END OF CONFIGURABLE SECTIONif (file_exists($datafile) === FALSE) { echo “Cannot find $datafile”; exit; }
$data = explode(" ",file_get_contents($datafile));if ($cumulus == 1) {
$fdate = $data[0];
$ftime = $data[1];
$temp = $data[2];
$hum = $data[3];
$dew = $data[4];
$wspeed = $data[6];
$wgust = $data[40];
$winddir = $data[7];
$rainday = $data[9];
$baro = $data[10];
$windunit = $data[13];
$tempunit = $data[14];
$barounit = $data[15];
$rainunit = $data[16];
$rainhour = $data[47];
}
else {
$fdate = $data[74];
$ftime = “{$data[29]}:{$data[30]}:{$data[31]}”;
$temp = $data[4];
$dew = $data[72];
$hum = $data[5];
$wspeed = $data[1];
$wgust = $data[140];
$winddir = $data[3];
$rainday = $data[7];
$baro = $data[6];
$windunit = “kts”;
$tempunit = “c”;
$barounit = “hpa”;
$rainhour = 0; //cludge for now till I can find a better way to do it.
$rainunit = “mm”;
}if (stristr($tempunit,“c”)) {
$temp = ConvertCtoF($temp);
$dew = ConvertCtoF($dew);
}if (stristr($windunit,“kts”)) {
$wspeed = KTStoMPH($wspeed,2);
$wgust = KTStoMPH($wgust,2);
}if ((stristr($barounit,“hpa”)) OR (stristr($barounit,“mb”))) {
$baro = HPAtoINHG($baro);
}if (stristr($rainunit,“mm”)) {
$rainday = MMtoINCHES($rainday);
$rainhour = MMtoINCHES($rainhour);
}$time = explode(“:”,$ftime);
$date = explode(“/”,$fdate);
$ourdate = mktime($time[0],$time[1],$time[2],$date[1],$date[0],$date[2]);
if (date(‘I’) == 1) { $ourdate = strtotime(“-1 hour”,$ourdate); }$oururl = “http://weatherstation.wunderground.com/weatherstation/updateweatherstation.php?ID={$siteid}&PASSWORD={$authenticationpin}”;
$oururl .= “&dateutc=” .urlencode(date(‘Y-m-d G:i:s’,$ourdate));
$oururl .= “&winddir={$winddir}&windspeedmph={$wspeed}&windgustmph={$wgust}&humidity={$hum}&dewptf={$dew}”;
$oururl .= “&tempf={$temp}”;
$oururl .= “&rainin={$rainhour}&dailyrainin={$rainday}&baromin={$baro}”;
$oururl .= “&softwaretype={$softwaretype}&action=updateraw”;
echo “Sending:
$oururl”;if ($useCURL == 1) {
$ch = curl_init();
$timeout = 30;
curl_setopt($ch,CURLOPT_URL,$oururl);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$ret = curl_exec($ch);
curl_close($ch);
} else {
$ret = file_get_contents($oururl);
}function ConvertMPHtoKTS($mph) {
$kts = $mph * 0.868976242;
return $kts;
}function ConvertCtoF($degc) {
$degf = round($degc = ((1.8* $degc) + 32),2);
return $degf;
}// MMtoINCHES: converts mm to inches
function MMtoINCHES($value) {
return round($value = (0.0393700787 * $value),2);
} // end function MMtoINCHES// HPAtoINHg: converts hPa to inHg
function HPAtoINHG($value) {
return round($value = (0.295300 * $value)/10,2);
} // end function HPAtoINHG// KTStoMPH: converts KTS to MPH
function KTStoMPH($value, $precision) {
// global $wind_prec;
return round($value = (1.1507794 * $value),$precision);
} // end function KTStoMPH?>
Very good!
no thanks to you niko for the wiki tip and to Andrew for the wow met o script!
I would think that should read thanks to you Niko?
I’m going to assume “no thanks” is a typo :lol:
whoops!
omitted a comma!
you said “very good”
I intended to reply “no, thanks to YOU”
thanks for not being immediately offended!
thanks Brian.
thanks Niko.
Nice to see a good project come together so quickly.