WXforum.net
Weather Software => WeatherLink/weatherlink.com by Davis Instruments => Topic started by: sheldon on October 24, 2014, 07:39:10 PM
-
Hi, guys, I'm from Italy! (I apologize by now for my English)
I am having some problems for making my website for my Davis Vantage Vue Station, because I'm using Weatherlink IP.
First, I would like to know if a pre-compiled weather template exists for it (I'm not so good in making website pages), this could resolve all my problems.
If it doesn't exist, can you look at this code and tell me what is wrong?
The problem is that it shows on the webpage only some variables and not all. For example, temperature, relative humidity, wind speed, wind direction, are showed, while all the other variables aren't, even if in the code I defined them in the same way.
<?php
$url = "http://www.weatherlink.com/xml.php?user=romaeur&pass=***";
$ip = @file_get_contents($url);
$object = simplexml_load_string($ip);
$davis_current = $cur_obs->davis_current_observation;
$cur_obs = simplexml_load_string($ip);
$xml = simplexml_load_file('http://www.weatherlink.com/xml.php?user=romaeur&pass=***');
foreach($object->temp_day_high_f as $tmaxf);
$tmax = round(5/9*($tmaxf+32),1);
foreach($xml->temp_day_low_f as $tminf);
$tmin = round(5/9*($tminf+32),1);
$objum = simplexml_load_string($ip);
foreach($cur_obs->relative_humidity_day_high as $hummax);
foreach($xml->relative_humidity_day_low as $hummin);
foreach($xml->temp_day_high_time as $tmaxh);
foreach($xml->relative_humidity as $hum);
foreach($object->temp_c as $temp);
foreach($xml->heat_index_c as $heat);
foreach($xml->observation_time as $ultimo_aggiornamento);
foreach($xml->temp_day_high_f as $max);
foreach($xml->wind_kt as $velventos);
$velvento = round($velventos * 1.85,1);
foreach($xml->wind_dir as $dirvento);
foreach($xml->wind_degrees as $grvento);
foreach($xml->pressure_mb as $press);
foreach($xml->windchill_c as $chill);
?>
<?php
foreach($xml->rain_day_in as $prec);
foreach($xml->rain_rate_in_per_hr as $rrate);
foreach($xml->temp_day_low_time as $tminh);
foreach($xml->pressure_day_high_in as $pressmax);
foreach($xml->pressure_day_high_time as $pressmaxh);
foreach($xml->pressure_day_low_time as $pressminh);
foreach($xml->pressure_day_low_in as $pressmin);
This is the web page
http://romaeurmeteo.it/home.php
I obviously didn't insert all the code but only the part with variables definition
Thank you very much
-
What sort of computer/system are you using?
If it's a Windows system, have you tried using the WeatherLink software?
-
Hello, Sheldon... Been using Vue + Weatherlink IP with VWS for over 4 Years, with Ken's Saratoga templates....
what could be simpler?
Mike
-
The problem is that I bought Weatherlink IP for not using a pc to send my data on a website. I want to avoid it!
And the only way to make up a personal website with my live data is to create it by getting them from my personal page on Weatherlink.com, where automatically the Weatherlink IP hardware sends the data!
-
The problem is that I bought Weatherlink IP for not using a pc to send my data on a website. I want to avoid it!
And the only way to make up a personal website with my live data is to create it by getting them from my personal page on Weatherlink.com, where automatically the Weatherlink IP hardware sends the data!
-
Hi, guys, I'm from Italy! (I apologize by now for my English)
I am having some problems for making my website for my Davis Vantage Vue Station, because I'm using Weatherlink IP.
First, I would like to know if a pre-compiled weather template exists for it (I'm not so good in making website pages), this could resolve all my problems.
If it doesn't exist, can you look at this code and tell me what is wrong?
The problem is that it shows on the webpage only some variables and not all. For example, temperature, relative humidity, wind speed, wind direction, are showed, while all the other variables aren't, even if in the code I defined them in the same way.
. . . shortened . . .
I obviously didn't insert all the code but only the part with variables definition
Thank you very much
There are two parts in the xml.
The first part with, in general, the recent fields.
The second part which is contained in the firts part has mostly min/max measurements and date time fileds.
So
$xml = your weatherlink.com xml
With $xml -> field name you address fields as temp_c
With $xml -> davis_current_observation -> field name you address fields as temp_day_high_f
Important: In the first part the fields have metric (C) and imperial (F) as unit of measurement.
The second part has only imperial fields. You have to write conversion instructions for in to mm and F to C.
I enclosed a small example program which will display:
We can use for the fileds in the second part:
Pressmax using the long way : 30.061
Pressmax using the short way: 30.061
some xml fields: mostly current ones form the first part
$dirvento = Southwest
$press = 1018.0
some obs fields: mostly high lows and time
$pressmax = 30.061
$pressmaxh = 6:40pm
-
The problem is that I bought Weatherlink IP for not using a pc to send my data on a website. I want to avoid it!
And the only way to make up a personal website with my live data is to create it by getting them from my personal page on Weatherlink.com, where automatically the Weatherlink IP hardware sends the data!
In my other post I adressed your question about the fields in the xml.
Just one question on top:
Why do you do it the difficult way?
You do not want a full-blown PC 24/24 to send data to your own website.
But for less then 100 euro you could by a device such as metebridge and upload your data to Weatherlink.com with the WLIP you already have AND
upload the data in the format you want to your website using the meteobridge .
And the electricity used is far less then the smallest PC you can imagine. No manual upgrades, install and forget it.
You could then use the Saratoga- or Leuven-template as a starting point.
And / or you could also develop your own pages.
But the weather device (be it a meteobridge or a raspberryPI or whatever) can give you far more data then the WL.com xml.
Wim
-
The problem is that I bought Weatherlink IP for not using a pc to send my data on a website. I want to avoid it!
And the only way to make up a personal website with my live data is to create it by getting them from my personal page on Weatherlink.com, where automatically the Weatherlink IP hardware sends the data!
In my other post I adressed your question about the fields in the xml.
Just one question on top:
Why do you do it the difficult way?
You do not want a full-blown PC 24/24 to send data to your own website.
But for less then 100 euro you could by a device such as metebridge and upload your data to Weatherlink.com with the WLIP you already have AND
upload the data in the format you want to your website using the meteobridge .
And the electricity used is far less then the smallest PC you can imagine. No manual upgrades, install and forget it.
You could then use the Saratoga- or Leuven-template as a starting point.
And / or you could also develop your own pages.
But the weather device (be it a meteobridge or a raspberryPI or whatever) can give you far more data then the WL.com xml.
Wim
I didn't know about this, but for now I can't spend other money (the weather station and the datalogger had their price).
I saw a lot of cute websites realized by getting the data from the weatherlink.com xml, and I was wondering if someone had created a template for weatherlink IP users, which defines the variables and has a good graphic interface.
Otherwise, I have to create my webpage by the codes.
Anyway, thank you very much for telling me how to get the data that I couldn't insert in my page!!
Now it is working, I just have some problems with the conversions, because some values don't correspond exactly to the ones are showed on the weatherlink.com page.
-
. . . shortened . . . I just have some problems with the conversions, because some values don't correspond exactly to the ones are showed on the weatherlink.com page.
In the first part (the point-measurements = the current values) of the xml there are metric (mm, C, mb) and imperial (in, mph) values available.
In the second part (the min max per day month and so on) there are only imperial measurements.
So wind in mph, temp in F and the dates are in AM/PM.
The units in the xml are for general use. The way they are displayed on WeatherLink.com is done by your settings, or other visitors settings on Weatherlink.com
Succes, Wim
-
Your weather page at http://www.romaeurmeteo.it/home.php
would be much more useful if it included the date and time of the last update.
-
. . . shortened . . . I just have some problems with the conversions, because some values don't correspond exactly to the ones are showed on the weatherlink.com page.
In the first part (the point-measurements = the current values) of the xml there are metric (mm, C, mb) and imperial (in, mph) values available.
In the second part (the min max per day month and so on) there are only imperial measurements.
So wind in mph, temp in F and the dates are in AM/PM.
The units in the xml are for general use. The way they are displayed on WeatherLink.com is done by your settings, or other visitors settings on Weatherlink.com
Succes, Wim
To solve this problem I provided a conversion code in the php file as follows:
foreach($xml->davis_current_observation->temp_day_low_f as $tminf);
foreach($xml->davis_current_observation->temp_day_high_f as $tmaxf);
$tmax = round((5/9) * ($tmaxf - 32),1);
$tmin = round((5/9) * ($tminf - 32),1);
but it doesn't give a satisfactory result, infact the values are not exactly the same. Look at the following two screens, the first by my website, the second from weatherlink.com page:
(In the meanwhile I changed my home's aspect:
http://romaeurmeteo.it/index.php/
-
Can anybody help me?
-
Can anybody help me?
The problem is that it is somewhere in your code, but nobody else but you can look into that code.
PHP is executed on the webserver into =>HTML, which is then send => to the browser.
So we only see the results. Not the code.
And we have no access to your xml to check what is going into the PHP.
=== Other WL.com scripts have no problem
I have my own Weatherlink.com template scripts:
http://www.weerstation-leuven.be/weatherWLC/ (http://www.weerstation-leuven.be/weatherWLC/)
Remark: The test-site runs for a website in Vancouver Canada so the "last updated" times are recalculated for Vancouver timezone but the xml is recent for Leuven-time.
The xml from my station in Leuven is used:
http://www.weatherlink.com/user/wvdkuil/index.php?view=summary&headers=1 (http://www.weatherlink.com/user/wvdkuil/index.php?view=summary&headers=1)
There are no differences between the WL.com xml and the converted values to metric. Neither on WL.com as on my site.
This script is used to read the xml, convert it to needed UOMs (unit of measurent - C F and so on.) and cache the result for reuse if a next request is arriving very fast.
http://www.weerstation-leuven.be/weatherWLC/uploadXX/tagsWLCOM.php?sce=view (http://www.weerstation-leuven.be/weatherWLC/uploadXX/tagsWLCOM.php?sce=view)
=== Add debug / test code
As with most scripts, at least 20% of the code of the scripts above is debugging code to understand what is going on.
What you should do to tackle the problem:
1. Load one xml file and put that in a local file on your webserver.
You are going to use that file to test until you are satisfied.
Also later on when you change something in your scripts you should use that test-file first.
2. Change te loading procedure with a setting to either load the xml form WL.com (using userid and password) or from the local test-file. Use a setting default to false, only when you change it to true the test is
3. Use a few extra lines around the fields with the error.
if ($test) {
echo <pre>.PHP_EOL;
echo $your xml filed before any conversion.' - '.$your field after conversion.PHP_EOL;
}
=== your remark: in fact the values are not exactly the same
This can have many reasons, and again without the code it is only guessing:
Is the conversion routine wrong:
Are some fields correct -or- are they all in error?
Did you make a typo when copying:
Did you put the conversion in a function- or- did you copy it multiple times?
A simple programming error;
Same fieldname used on multiple locations?
=== Give us some info to help you.
Many people on this forum want to help. But without the php.code and the xml we can not do anything.
It would be wise to first make a small script which converts (parts of) the xml and separate that from your web-page.
Than you can post that script and the test xml so we can take a look.
Wim
-
This is the xml file:
<current_observation xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" xsi:noNamespaceSchemaLocation="http://www.weather.gov/view/current_observation.xsd">
<credit>Davis Instruments Corp.</credit>
<credit_URL>http://www.davisnet.com</credit_URL>
<image>
<url>
http://www.weatherlink.com/images/Logo_Davis_reflxblu.jpg
</url>
<title>Davis WeatherLink</title>
<link>http://www.weatherlink.com</link>
</image>
<suggested_pickup>15 minutes after the hour</suggested_pickup>
<suggested_pickup_period>60</suggested_pickup_period>
<dewpoint_c>6.1</dewpoint_c>
<dewpoint_f>43</dewpoint_f>
<dewpoint_string>43 F (6.1 C)</dewpoint_string>
<heat_index_c>15.0</heat_index_c>
<heat_index_f>59</heat_index_f>
<heat_index_string>59 F (15.0 C)</heat_index_string>
<latitude>41.825448062796</latitude>
<location>Roma, RM, Italia</location>
<longitude>12.477133083343</longitude>
<observation_time>Last Updated on Oct 30 2014, 7:35 pm CET</observation_time>
<observation_time_rfc822>Thu, 30 Oct 2014 19:35:05 +0100</observation_time_rfc822>
<pressure_in>30.109</pressure_in>
<pressure_mb>1019.6</pressure_mb>
<pressure_string>1019.6 mb</pressure_string>
<relative_humidity>52</relative_humidity>
<station_id>romaeur</station_id>
<temp_c>16.1</temp_c>
<temp_f>60.9</temp_f>
<temperature_string>60.9 F (16.1 C)</temperature_string>
<wind_degrees>331</wind_degrees>
<wind_dir>Northwest</wind_dir>
<wind_kt>2</wind_kt>
<wind_mph>2</wind_mph>
<windchill_c>16.1</windchill_c>
<windchill_f>61</windchill_f>
<windchill_string>61 F (16.1 C)</windchill_string>
<davis_current_observation version="1.0">
<observation_age>54</observation_age>
<dewpoint_day_high_f>53</dewpoint_day_high_f>
<dewpoint_day_high_time>12:00am</dewpoint_day_high_time>
<dewpoint_day_low_f>40</dewpoint_day_low_f>
<dewpoint_day_low_time>4:16pm</dewpoint_day_low_time>
<dewpoint_month_high_f>71</dewpoint_month_high_f>
<dewpoint_month_low_f>30</dewpoint_month_low_f>
<dewpoint_year_high_f>71</dewpoint_year_high_f>
<dewpoint_year_low_f>30</dewpoint_year_low_f>
<heat_index_day_high_f>68</heat_index_day_high_f>
<heat_index_day_high_time>1:12pm</heat_index_day_high_time>
<heat_index_month_high_f>85</heat_index_month_high_f>
<heat_index_year_high_f>85</heat_index_year_high_f>
<pressure_day_high_in>30.14</pressure_day_high_in>
<pressure_day_high_time>9:33am</pressure_day_high_time>
<pressure_day_low_in>30.08</pressure_day_low_in>
<pressure_day_low_time>3:54pm</pressure_day_low_time>
<pressure_month_high_in>30.266</pressure_month_high_in>
<pressure_month_low_in>29.589</pressure_month_low_in>
<pressure_tendency_string>Rising Slowly</pressure_tendency_string>
<pressure_year_high_in>30.339</pressure_year_high_in>
<pressure_year_low_in>29.589</pressure_year_low_in>
<rain_day_in>0.0000</rain_day_in>
<rain_month_in>2.3780</rain_month_in>
<rain_rate_day_high_in_per_hr>0.0000</rain_rate_day_high_in_per_hr>
<rain_rate_hour_high_in_per_hr>0.0000</rain_rate_hour_high_in_per_hr>
<rain_rate_in_per_hr>0.0000</rain_rate_in_per_hr>
<rain_rate_month_high_in_per_hr>10.0787</rain_rate_month_high_in_per_hr>
<rain_rate_year_high_in_per_hr>10.0787</rain_rate_year_high_in_per_hr>
<rain_storm_in>0.0236</rain_storm_in>
<rain_storm_start_date>10/13/2014</rain_storm_start_date>
<rain_year_in>2.3937</rain_year_in>
<relative_humidity_day_high>94</relative_humidity_day_high>
<relative_humidity_day_high_time>12:00am</relative_humidity_day_high_time>
<relative_humidity_day_low>36</relative_humidity_day_low>
<relative_humidity_day_low_time>2:30pm</relative_humidity_day_low_time>
<relative_humidity_in>61</relative_humidity_in>
<relative_humidity_in_day_high>65</relative_humidity_in_day_high>
<relative_humidity_in_day_high_time>1:50am</relative_humidity_in_day_high_time>
<relative_humidity_in_day_low>60</relative_humidity_in_day_low>
<relative_humidity_in_day_low_time>6:08pm</relative_humidity_in_day_low_time>
<relative_humidity_in_month_high>78</relative_humidity_in_month_high>
<relative_humidity_in_month_low>35</relative_humidity_in_month_low>
<relative_humidity_in_year_high>78</relative_humidity_in_year_high>
<relative_humidity_in_year_low>35</relative_humidity_in_year_low>
<relative_humidity_month_high>97</relative_humidity_month_high>
<station_name>Roma EUR meteo</station_name>
<sunrise>6:41am</sunrise>
<sunset>5:08pm</sunset>
<temp_day_high_f>69.7</temp_day_high_f>
<temp_day_high_time>2:25pm</temp_day_high_time>
<temp_day_low_f>51.2</temp_day_low_f>
<temp_day_low_time>5:10am</temp_day_low_time>
<temp_in_day_high_f>69.6</temp_in_day_high_f>
<temp_in_day_high_time>12:00am</temp_in_day_high_time>
<temp_in_day_low_f>68.3</temp_in_day_low_f>
<temp_in_day_low_time>1:05pm</temp_in_day_low_time>
<temp_in_f>69.1</temp_in_f>
<temp_in_month_high_f>80.7</temp_in_month_high_f>
<temp_in_month_low_f>68.1</temp_in_month_low_f>
<temp_in_year_high_f>80.7</temp_in_year_high_f>
<temp_in_year_low_f>68.1</temp_in_year_low_f>
<temp_month_high_f>83.6</temp_month_high_f>
<temp_month_low_f>47.2</temp_month_low_f>
<temp_year_high_f>83.6</temp_year_high_f>
<temp_year_low_f>47.2</temp_year_low_f>
<wind_day_high_mph>17</wind_day_high_mph>
<wind_day_high_time>4:59pm</wind_day_high_time>
<wind_month_high_mph>31</wind_month_high_mph>
<wind_ten_min_avg_mph>3</wind_ten_min_avg_mph>
<wind_year_high_mph>31</wind_year_high_mph>
<windchill_day_low_f>51</windchill_day_low_f>
<windchill_day_low_time>5:04am</windchill_day_low_time>
<windchill_month_low_f>47</windchill_month_low_f>
<windchill_year_low_f>47</windchill_year_low_f>
</davis_current_observation>
<disclaimer_url>http://www.davisnet.com/about/terms.asp</disclaimer_url>
<copyright_url>http://www.davisnet.com/about/terms.asp</copyright_url>
<privacy_policy_url>http://www.davisnet.com/about/privacy.asp</privacy_policy_url>
<time_to_generate>0.046802997589111</time_to_generate>
</current_observation>
And this is my php file with the definitions of the variables
<?php
$url = "http://www.weatherlink.com/xml.php?user=romaeur&pass=*****";
$ip = @file_get_contents($url);
$object = simplexml_load_string($ip);
$davis_current = $cur_obs->davis_current_observation;
$cur_obs = simplexml_load_string($ip);
$xml = simplexml_load_file('http://www.weatherlink.com/xml.php?user=romaeur&pass=********');
#Dati attuali
foreach($xml->observation_time as $ultimo_aggiornamento);
foreach($xml->temp_c as $temp);
foreach($xml->heat_index_c as $heat);
foreach($xml->relative_humidity as $hum);
foreach($xml->wind_kt as $velventos);
$velvento = round($velventos * 1.85,1);
foreach($xml->wind_dir as $dirvento);
foreach($xml->wind_degrees as $grvento);
foreach($xml->pressure_mb as $press);
foreach($xml->windchill_c as $chill);
foreach($xml->dewpoint_c as $dew);
foreach($xml->davis_current_observation->rain_day_in as $precs);
foreach($xml->davis_current_observation->rain_rate_in_per_hr as $rrates);
foreach($xml->davis_current_observation->rain_storm_in as $storms);
foreach($xml->davis_current_observation->rain_rate_hour_high_in_per_hr as $maxrrhs);
foreach($xml->davis_current_observation->rain_rate_day_high_in_per_hr as $maxrrds);
$prec = round($precs / 0.039370,1);
$rrate = round($rrates / 0.039370,1);
$storm = round($storms / 0.039370,1);
$maxrrh = round($maxrrhs / 0.039370,1);
$maxrrd = round($maxrrds / 0.039370,1);
#Max e Min
foreach($xml->davis_current_observation->relative_humidity_day_high as $hummax);
foreach($xml->davis_current_observation->relative_humidity_day_low as $hummin);
foreach($xml->davis_current_observation->temp_day_low_f as $tminf);
foreach($xml->davis_current_observation->temp_day_high_f as $tmaxf);
$tmax = round((5/9) * ($tmaxf - 32),1);
$tmin = round((5/9) * ($tminf - 32),1);
foreach($xml->davis_current_observation->temp_day_high_time as $tmaxh);
foreach($xml->davis_current_observation->temp_day_high_f as $max);
foreach($xml->davis_current_observation->temp_day_low_time as $tminh);
foreach($xml->davis_current_observation->pressure_day_high_in as $pressmaxin);
foreach($xml->davis_current_observation->pressure_day_high_time as $pressmaxh);
foreach($xml->davis_current_observation->pressure_day_low_time as $pressminh);
foreach($xml->davis_current_observation->pressure_day_low_in as $pressminin);
$pressmax = round($pressmaxin * 33.86, 1);
$pressmin = round($pressminin * 33.86, 1);
foreach($xml->davis_current_observation->relative_humidity_day_low_time as $humminh);
foreach($xml->davis_current_observation->relative_humidity_day_high_time as $hummaxh);
foreach($xml->davis_current_observation->wind_day_high_mph as $rafmaxs);
$rafmax = round($rafmaxs * 1.6,1);
foreach($xml->davis_current_observation->sunrise as $alba);
foreach($xml->davis_current_observation->sunset as $tram);
if ($grvento > 348.75 AND $grvento <=11.25) { $grvento = N; }
if ($grvento > 11.25 AND $grvento <=33.75) { $grvento = NNE; }
if ($grvento > 33.75 AND $grvento <=56.25) { $grvento = NE; }
if ($grvento > 56.25 AND $grvento <=78.75 ) { $grvento = ENE; }
if ($grvento > 78.75 AND $grvento <=101.25 ) { $grvento = E; }
if ($grvento > 101.25 AND $grvento <=123.75) { $grvento = ESE; }
if ($grvento > 123.75 AND $grvento <=146.25) { $grvento = SE; }
if ($grvento > 146.25 AND $grvento <=168.65) { $grvento = SSE; }
if ($grvento > 168.65 AND $grvento <=191.25) { $grvento = S; }
if ($grvento > 191.25 AND $grvento <=213.75) { $grvento = SSO; }
if ($grvento > 213.75 AND $grvento <=236.25) { $grvento = SO; }
if ($grvento > 236.25 AND $grvento <=258.65) { $grvento = OSO; }
if ($grvento > 258.65 AND $grvento <=281.25) { $grvento = O; }
if ($grvento > 281.25 AND $grvento <=303.75) { $grvento = ONO; }
if ($grvento > 303.75 AND $grvento <=326.25) { $grvento = NO; }
if ($grvento > 326.25 AND $grvento <=348.75) { $grvento = NNO; }
if ($grvento > 338 AND $grvento <=360) { $grvento = N; }
?>
Thank you
-
I noticed that if I don't make any convertion and I make the Fahrenheit temperature appear, the right value appears. The problem comes when I set a conversion from Fahrenheit to Celsius, but one only formula exists to make this conversion and I set that. :/
-
I finally solved the problem!
This is how:
foreach($xml->davis_current_observation->temp_day_low_f as $tminff);
foreach($xml->davis_current_observation->temp_day_high_f as $tmaxff);
$tmaxf = (float)$tmaxff;
$tminf = (float)$tminff;
$tmax = round((5/9) * ($tmaxf - 32),1);
$tmin = round((5/9) * ($tminf - 32),1);
The mysteries of programmation.... :roll:
This is my website now:
http://www.romaeurmeteo.it
Anyway...
I have another question for you \:D/
Can I get monthly and yearly data from the weatherlink page? Or the only data I can get are those in the xml file?
Thank you guys :grin: