Calculation of Sunshine Hours by NANO SD (via virtual-sensor?)

All about the standard Meteobridge devices based on mobile routers from TP-Link, D-Link, ASUS

Moderator: Mattk

Post Reply
xray77
Gold Boarder
Gold Boarder
Posts: 182
Joined: Sat Mar 07, 2020 11:54 pm
Location: Buedelsdorf, SH Germany
Contact:

Calculation of Sunshine Hours by NANO SD (via virtual-sensor?)

Post by xray77 »

Hello,
I am looking for a way to have my MeteoBridge NANO SD determine the sunshine duration using the global radiation sensor of the Vantage Pro.

The necessary data like latitude and longitude of the station, maximum amount of radiation per day, time of day etc. are provided by MeteoBridge, it only fails because of the conversion of a formula to calculate the respective (Time of day dependent) global radiation threshold value for sun yes or no.

Has someone already written a template / script that he could provide me with? That would be great!

By the way, the script provided in the graphic template for the generation of a sunshine graphic (sunshine.chart) does not work. In my opinion a sensor is addressed here which is not defined in MeteoBridge:

#METEOBRIDGE#data{date:"[YYYY]-[MM]-[DD] [hh]:[mm]",s:[sun0total-sum.1:void 0],ss:inc([sun0total-sum.1:void 0]),d:dl([YYYY],[MM],[DD])}
Is there perhaps a solution for this?

Thanks a lot for tips / help
Greetings
Michael
Last edited by xray77 on Tue Apr 21, 2020 11:57 am, edited 2 times in total.
User avatar
admin
Platinum Boarder
Platinum Boarder
Posts: 7874
Joined: Mon Oct 01, 2007 10:51 pm

Re: Calculation of Sunshine Hours by MeteoBridge NANO SD

Post by admin »

You need a station that reports sunshine duration. Yours does not.
xray77
Gold Boarder
Gold Boarder
Posts: 182
Joined: Sat Mar 07, 2020 11:54 pm
Location: Buedelsdorf, SH Germany
Contact:

Calculation of Sunshine Hours by NANO SD (formula found..)

Post by xray77 »

Hello,
I have found a way to let MeteoBridge calculate the sunshine duration per minute (yes=1 or no=0):

#if#{*[hh]*60+[mm]<802&&[sol0rad-act.0 :--]>0*0}#then#{*[hh]*60+[mm]-((1440-[mbsystem-daylength=mins:0:--])/2+82)*([mbsystem-solarmax:0:--]+50)/([mbsystem-daylength=mins:0:--])-37-[sol0rad-act:0:--]<01*0}#else#{*([sol0rad-act.0 :--]>0)&&1440-([hh]*60+[mm])-((1440-[mbsystem-daylength=mins:0:--])/2-82)*(([mbsystem-solarmax:0:--]+50)/([mbsystem-daylength=mins:0:--]))-15-[sol0rad-act.0:--]<01*0}#fi# min
Result displayed in html-file, which must refresh every minute
Result displayed in html-file, which must refresh every minute
Bildschirmfoto 2020-04-14 um 11.57.55.png (14.28 KiB) Viewed 1643 times
The "else"-block calculate the sunshine at afternoon, cause the base-solar-radiation-value must step down past the sun-zenith...
Although the calculation is not scientific, as it assumes, for example, that the sun-zenith-time is set to a fix time (13:22) , it is sufficiently accurate, at least for the time being.

Is it possible to set up a virtual sensor that counts these events per minute using the above calculation (sun yes +1, sun no +0) and then outputs a sunshine duration at the end of the day and I could then have it displayed graphically?
This ist my first question and would be my preferred solution.

Link to see results: (Page automatically refresh every minute)
https://buedelsdorfwetter.de/meteobridge/sun.html

I had found another script in the SwissWetter-Forum, which describes the possibility of setting up a virtual sensor via awk-Script and also does a sunshine calculation, but on a MeteoPlug. Would such a script also work on a MeteoBridge?

Source: weather station Zunzgen (Basel-Land): wetter.isenegger.org
SwissWeather-Forum:

Define in meteoplug a virtual sensor "data_" (in my case data38) with the following gawk script (trigger: sol0):

awk '{c=$3;lg=7.8;lt=47.45;d=0.0174533;j=strftime(''%j'');st=strftime(''%H'')--1;mi=strftime(''%M'');}{x=-23.45*cos(d*360*(j--10)/365);z=60*(-0.171*sin(0.0337*j--0.465)-0.1299*sin(0.01787*j-0. 168));w=15*(st--mi/60-(15-lg)/15-12--z/60);s=sin(d*lt)*sin(d*x)--cos(d*lt)*cos(d*x)*cos(d*w);s2=atan2(s,sqrt(1-s^2))/d;m=1368*sin(s2*d);a=(1-sin(s2*d))*0. 3*m;g=(m-a)*0.5;if (st<8 ) g=g*0.8-3;if (st>14) g=g*1.2--5;o=0;if ((c>g)&&(g>15)) o=100;printf''%d'',o}'


Since the max.length of the script line is limited, the code is "awful" implemented, but it works.


Unfortunately the author is not available by mail, so I could not ask him. I don't know, how I can create an "virtual sensor" on MeteBridge and how often the script must be run, if it is possible to do it like this..

Thanks for tips
Michael
Attachments
Sunshine yet..
Sunshine yet..
Bildschirmfoto 2020-04-14 um 12.03.35.png (392.84 KiB) Viewed 1641 times
xray77
Gold Boarder
Gold Boarder
Posts: 182
Joined: Sat Mar 07, 2020 11:54 pm
Location: Buedelsdorf, SH Germany
Contact:

Re: Calculation of Sunshine Hours by NANO SD (via virtual-sensor?)

Post by xray77 »

Hello,
I want to take my thread upstairs again.

Is there really no possibility to integrate my formula for sunshine calculation via script into Meteobridge NANO SD using the global radiation sensor of Vantage via a virtual sensor?

I'm currently having the formula calculated and displayed every minute as HTML page of MB NANO SD:
https://buedelsdorfwetter.de/meteobridge/sun.html.
You will see some weather-data and the sun on the right side, beyond some raw-data for testing purposes..
Actually i let import the result in a local Database, the database calculate also some other statistics and of course the sunshine-hours from the data of the MeteoBridge..
This is the code-printing-part of the calculation of sun or not which is running on a nearly similar website:

<td><nobr>#if#{*[hh]*60+[mm]<802&&[sol0rad-act.0:0]>0&&([hh]*60+[mm]-((1440-[mbsystem-daylength=mins:0:--])/2+82)-10)>0*0}#then#{*[hh]*60+[mm]-((1440-[mbsystem-daylength=mins:0:--])/2+82)*(([mbsystem-solarmax:0:0]+50)/([mbsystem-daylength=mins:0:--]))-((802-(([hh]*60+[mm])-(([hh]*60+[mm])-((1440-[mbsystem-daylength=mins:0:--])/2+82))))-([hh]*60+[mm]-((1440-[mbsystem-daylength=mins:0:--])/2+82)))*(45/(([mbsystem-daylength=mins:0:--]/2)))-[sol0rad-act:0:0]<01*0}#else#{*([sol0rad-act.0:0]>0)&&(1440-([hh]*60+[mm])-((1440-[mbsystem-daylength=mins:0:--])/2-82)-10)>0&&1440-([hh]*60+[mm])-((1440-[mbsystem-daylength=mins:0:--])/2-82)*(([mbsystem-solarmax:0:0]+50)/([mbsystem-daylength=mins:0:--]))-((([hh]*60+[mm]-((1440-[mbsystem-daylength=mins:0:--])/2+82))-(([mbsystem-daylength=mins:0:--]/2)))*(34/(([mbsystem-daylength=mins:0:--]/2))))-[sol0rad-act.0:0]<01*0}#fi# min</nobr></td>

Some explanations of the code:
-> <802 = the estimated max-sun-elevation-time in minutes (13:22), only run this part of code until 13:22
-> [sol0rad-act.0:0]>0 = only run the code if solar-radiation is greater than 0
-> ([hh]*60+[mm]-((1440-[mbsystem-daylength=mins:0:--])/2+82)-10)>0 = only run the code if the minutes from sunrise to now are greater then 0

after the #else# the calculation for the afternoon begins
-> ([sol0rad-act.0:0]>0)&&(1440-([hh]*60+[mm])-((1440-[mbsystem-daylength=mins:0:--])/2-82)-10)>0 = the solar-radiation must be greater than 0, The sunset-time (in minutes) minus 10 minutes offset must be greater than 0

in the end of all stands the explanation 1 for sun or 0 for no sun. The code must be written in this "horrible"-chain-format due to limitations of calculating-methods of the MeteoBridge... Unfortunately there is no possibility to create own variables for the calculating-values like php or so.. Unfortunately i have no knowhow to programming in php or similar languages... :-(
A max-solar elevation at 13:22 CEST (12:22 CET) is used as a fixed value and a local correction value of +45W/m2 in the morning after sunrise is taken into account, which is reduced until the max-solar elevation (then +0 W/m2 ) is reached. In the afternoon, a local correction factor of 34 W/m2 is taken into account, which is applied from the max-solar elevation (0 W/m2) until sunset (-34 W/m2).
The local correction factors cannot be fixed, they must be adjusted according to local conditions.
The other necessary data are already available in MB Nano SD variables.

Unfortunately I can't save the minutely values (sun yes=1, sun no =0) anywhere, because there is no sensor for this on the software side.
In the SwissWetter-Forum a possibility was described to set up a virtual sensor for sunshine-hours via script (post from 2014, the author had not respond to my mails until today):

https://www.swisswetterforum.ch/weather ... -meteoplug

Can this be done in the same way with an MB Nano SD? Or is it only possible with the larger Meteobridge PRO to set up something like this?
Maybe someone (Admin, Boris ?? :-) )has answers after all, that would be nice. Would really like to include the sunshine duration, in some circumstances it would be possible to integrate something for it in a future firmware-update of the MB-NANO-SD?
Best regards
Michael
Post Reply