Sunday, 22 January 2017

Davis weather station, WLink, PHP


Updated 2017-08-25 !

In the harbour we are using a Davis weather station, Vantage Pro2, as our PWS(Private Weather Station).

If You like to display the data, online on the web, You can use the Davis service, Weatherlink . We use the WeatherLinkIP to push the data to the web.

If You want to customise Your own website You could retrieve the weather data with serial communication direct from the WeatherLinkIP. There are some applications on Github but then, in this case, You have to have a server with Node.js

Another way is to retrieve the weather data as XML from the Weatherlink web-site.

Below You will find some PHP code which will do the work.



Get the XML data from the weatherlink site with Your credentials
$xml = simplexml_load_file('http://www.weatherlink.com/xml.php?user=XXXX&pass=YYYY');

Dump the whole XML data to see what is available
var_dump($xml);

And here I load some of the fields in an array
$cumulus[2] = $xml->{'temp_f'};
$cumulus[3] = $xml->{'relative_humidity'};
$cumulus[4] = $xml->{'dewpoint_f'};
$cumulus[5] = $xml->{'wind_mph'};   
$cumulus[22] = $xml->{'davis_current_observation'}->{'temp_in_f'}; 
$cumulus[23] = $xml->{'davis_current_observation'}->{'relative_humidity_in'};

The name "cumulus" comes from a project where I update a "realtime.txt" file which is one input for the weather34 template.  Despite the project is terminated the code is available and install instructions are here. In this case You also have to connect Your PWS to Weather underground to get the forecasts.

No comments:

Post a Comment