Go Down

Topic: Sunrise and Sunset (Read 2733 times) previous topic - next topic


I've been using an algorithm for a few years which works nicely within the limitations of microcontrollers and their ilk. I recently needed to dust it off for a port to the Arduino environment, and thought others may find it to be of use.

So I went the extra step to create a library, which can be downloaded from http://swfltek.com/arduino/sunrise.html.

The download page gives all the details, but in a nutshell...

Create an instance of the Sunrise class, specifying the location and timezone...
Ask it to produce the time of sunrise or sunset, for a particular date.
Pretty simple to use, fairly accurate, and easy on the resources.


Thanks for sharing this library. :)
I've been running it for a few days, and it's accurate to 1 or 2 min. Pretty cool!  8-)
"Data is not information, information is not knowledge, knowledge is not understanding, understanding is not wisdom."
~ Clifford Stoll



The algorithm should be correct to within 5 minutes out to the next century, as I recall. But the original used 'double' values, so since Arduino uses less accurate 'float' values, I was curious as to how accuracy would suffer.

I checked every day in 2009, and spot checks (solstices and equinoxes) out to 2050, and it reported values within 4 minutes of the 'correct' value (as given by a much more elaborate algorithm), so I am satisfied the Arduino version works OK.

Go Up