Skip to content

Commit 210b6e1

Browse files
committed
Add Examples, Notes and References sections
1 parent 90cea3d commit 210b6e1

1 file changed

Lines changed: 55 additions & 15 deletions

File tree

README.md

Lines changed: 55 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
# SolarCalculator Library for Arduino
22

3-
SolarCalculator is based on the
4-
[NOAA Solar Calculator](https://www.esrl.noaa.gov/gmd/grad/solcalc/).
3+
SolarCalculator is based on the [NOAA Solar Calculator](https://www.esrl.noaa.gov/gmd/grad/solcalc/).
54

6-
This library provides functions to calculate the Sun's position in the sky, the times of
7-
sunrise, sunset, twilight and solar noon for any location on earth, as well as the equation
8-
of time and more.
5+
This library provides functions to calculate the Sun's position in the sky, the times of sunrise, sunset, twilight and
6+
solar noon for any location on earth, as well as the equation of time and more.
7+
8+
Most formulae are taken from the textbook Astronomical Algorithms by Jean Meeus or the NOAA Solar Calculator
9+
[source code](https://gml.noaa.gov/grad/solcalc/main.js). Other sources are cited in the comments.
910

10-
Most formulae are taken from the textbook Astronomical Algorithms by Jean Meeus
11-
or the NOAA Solar Calculator [source code](https://gml.noaa.gov/grad/solcalc/main.js).
12-
Other sources are cited in the comments.
1311

1412
## Installation
1513

@@ -20,8 +18,8 @@ Download and copy SolarCalculator to your local Arduino/libraries directory.
2018
Date and time inputs are assumed to be in **Universal Coordinated Time** (UTC).
2119

2220
Although not required, it is recommended to use SolarCalculator along with the
23-
[Time](https://github.com/PaulStoffregen/Time) and
24-
[Timezone](https://github.com/JChristensen/Timezone) libraries.
21+
[Time](https://github.com/PaulStoffregen/Time) and [Timezone](https://github.com/JChristensen/Timezone) libraries.
22+
2523

2624
## Usage
2725

@@ -47,17 +45,17 @@ calcSunriseSunset(year, month, day, latitude, longitude, transit, sunrise, sunse
4745
```
4846
where the results are passed by reference, in hours.
4947

50-
Convert to local standard time, then to hours and minutes:
48+
Convert to local standard time:
5149
```
5250
double sunrise_local = sunrise + time_zone;
53-
51+
```
52+
To hours and minutes:
53+
```
5454
int minutes = int(round(sunrise_local * 60));
5555
int sunrise_local_hours = (minutes / 60) % 24;
5656
int sunrise_local_minutes = minutes % 60;
5757
```
58-
* Due to the varying effect of refraction, sunrise and sunset times should only be rounded
59-
to the nearest minute.
60-
58+
* Due to the varying effect of refraction, sunrise and sunset times should only be rounded to the nearest minute.
6159

6260
Similarly, calculate the times of civil, nautical and astronomical dawn and dusk:
6361
```
@@ -80,3 +78,45 @@ Calculate the equation of (ephemeris) time:
8078
```
8179
calcEquationOfTime(year, month, day, hour, minute, second, eq);
8280
```
81+
where the results are passed by reference, in degrees.
82+
83+
84+
## Examples
85+
86+
The following example sketches are included in this library:
87+
88+
* `SolarCalculatorTimeLib`: Calculate the times of sunrise, sunset, solar noon, twilight and the solar position for a
89+
given location. The Arduino Time library is used for timekeeping purposes.
90+
91+
* `SunriseSunset`: Calculate the times of sunrise, sunset, solar noon and twilight for a given date and location. No
92+
timekeeping required.
93+
94+
* `EquationOfTime`: Plot the equation of time for a given year.
95+
96+
97+
## Notes
98+
99+
### Sunrise and sunset
100+
101+
The algorithm for finding the times of sunrise and sunset implemented in this library is valid for all latitudes between
102+
the Arctic and Antarctic circles (about ± 66.5°). Outside this range, a more general algorithm should be used but is not
103+
provided at this time.
104+
105+
### Accuracy
106+
107+
Various things to consider:
108+
109+
* The amount of atmospheric refraction changes with air temperature, pressure, and the elevation of the observer.
110+
Therefore, sunrise and sunset times can only be accurate to the nearest minute (Meeus, 1998).
111+
112+
* Assuming a purely elliptical motion of the Earth, solar coordinates have a "low accuracy" of 0.01° (Meeus, 1998).
113+
114+
* Arduino's single precision floating numbers have the equivalent of `24 * log10(2)` ≈ 7.22 significant digits.
115+
Although this is generally not sufficient for mathematical astronomy (Meeus, 1998), it is sufficient for our solar
116+
calculations.
117+
118+
119+
## References
120+
121+
Meeus, J. (1998). *Astronomical algorithms* (2nd ed.). Willmann-Bell. <br />
122+
ESRL Global Monitoring Laboratory (n.d.). *NOAA Solar Calculator*. https://gml.noaa.gov/grad/solcalc/

0 commit comments

Comments
 (0)