Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.

Log in or register to post/reply in the forum.

Sunshine hours per day

osvaldojose Jul 18, 2019 12:18 PM

Hi there!

I need a help.

is that possible to add sushine per day to a program via CRBasic?

If yess how to do? Please send an example.

Thank you



Karl Dec 27, 2019 02:12 PM

Hello OJ,

I apologize for not getting back with you a few months ago, but the answer to your question is yes.  Do you still need an example program?


Karl Dec 27, 2019 02:38 PM


Check out ShortCut it has an option to write code for sunshine hours.  The option is located under the 'Calculations' section.


osvaldojose Apr 22, 2021 04:30 AM

Thank you Karl.

maurixio Apr 23, 2021 05:07 PM

i did it through a crbasic code, do you still need it?

Karl Apr 24, 2021 01:45 PM

You can use ShortCut or CRBasic, either works.  I would test the code to make sure it is working as expected - sometimes testing extremes are good tests.

osvaldojose Apr 25, 2021 09:48 AM

Yes I do need it. 

do you have a step by step or video showing how to add this functionality to a working program?

Thank you



Makada Apr 26, 2021 03:42 AM


Here you have an example:

'Calculate solar position
SolarPosition(SolPos(),RTime(),1*3600,your latitude,your longitude,0,BP_mbar,AirTC)
'Calculate potential radiation for time & position (multiply sine of solar elevation angle by solar constant 1373)
If PotSlrW<0 Then PotSlrW=0
'If the measured value (W/m^2) is greater than 0.4 * the potential solar radiation (W/m^2)
'and the sine of the sun elevation angle (degrees) is great than 0.1 (elevation angle of 6 degrees)
'than it has been sunny for the current scan.
If SlrW>0.4*PotSlrW And SIN(SunElevation)>0.1 Then
'Calculate sun hours for scan time in seconds
'Set sun hours for scan time in seconds to 0

osvaldojose Apr 26, 2021 03:56 AM

cool, this is it.

Thank Dear Makada for the help.


Osvaldo José

maurixio May 13, 2021 12:48 PM


The sunelevation parameter will depend on the latitude , longitude and the season of the year right?

Makada May 13, 2021 11:32 PM


Public solar_information(5)
Alias solar_information(1) = solar_azimuth
Alias solar_information(2) = sun_elevation
Alias solar_information(3) = hour_angle
Alias solar_information(4) = declination
Alias solar_information(5) = air_mass

SolarPosition(SolPos(),RTime(),1*3600,your latitude,your longitude,0,BP_mbar,AirTC)

Makada May 14, 2021 12:00 PM

No, i just used the instruction from CS Shortcut.


Sunshine Hours 

Heres a short description from the Sunshine hours instruction from CS Shortcut:

Sunshine HoursUnits for Sunshine Hours: Hours
Estimates if current weather is sunny by checking if current global radiation is higher than 0.4 times the current potential solar radiation outside the earth's atmosphere.
Sunshine Hours holds the hours of sunshine since the last scan. Totalise this value to give the total number of sunshine hours over any given period.
A solar radiation measurement (flux density) is required for this calculation, therefore, a solar radiation sensor must be selected and configured prior to selecting and configuring this calculation. The datalogger clock must be set to standard time, not daylight savings time.
You must specify latitude and longitude in decimal degrees. The range for Latitude is 0 to +90 (a positive value for the Northern hemisphere and a negative value for the Southern hemisphere). Longitude is also expressed in decimal degrees east of the Greenwich meridian. For longitudes measured going west from the Greenwich meridian, a negative value can be entered or a corrected value (e.g., 360 - West Degrees) can be used. For example, Tokyo, Japan has a longitude of 220.3 when measured going west which could be entered as -220.3 or the corrected longitude value of 139.7 degrees East could be used. 
TimeOffset is the local time offset, in hours, from UTC. If the datalogger setting "UTC Offset" is a value other than -1 (disabled), this offset will be ignored and the UTC Offset value from the datalogger will be used. (Note that UTC Offset is found in the datalogger's Settings table and is in seconds.

Or other posts about the subject:


Log in or register to post/reply in the forum.