MIT License

项目介绍

jpb10/SolarCalculator 是一个托管在 GitHub 上的开源项目,主要使用 C++ 编写,采用 MIT License 许可证,目前获得 72 个 Star、11 次 Fork。

仓库全名
jpb10/SolarCalculator
开源许可证
MIT License
Star 数
72
Fork 数
11

README 摘要

SolarCalculator Library for Arduino SolarCalculator is inspired by the NOAA Solar Calculator. This library provides functions to calculate the times of sunrise, sunset, solar noon, twilight (dawn and dusk), Sun's apparent position in the sky, equation of time, etc. Most formulae are taken from Astronomical Algorithms by Jean Meeus and optimized for Arduino. Installation Download and copy SolarCalculator to your…

完整内容见 GitHub 原始 README 或本页 。

常见问题

SolarCalculator 用什么语言开发?

主要使用 C++ 编写,采用 MIT License 许可证,目前有 72 个 Star。

SolarCalculator 可以免费商用吗?

仓库采用 MIT License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 SolarCalculator 的源码?

可以直接克隆仓库:git clone https://github.com/jpb10/SolarCalculator.git,默认分支为 main;安装与运行步骤见仓库 README。

SolarCalculator 最近还在维护吗?

仓库最近一次更新为 2025年5月18日,当前没有未关闭的 Issue;Star 数为 72,可作为社区活跃度的参考。

关于

Arduino library to calculate the times of sunrise, sunset, solar noon, twilight, the solar position, and more.

描述取自 GitHub 官方 API,中文内容由 GitRead 中文社区 编辑团队整理。

简要分析

热度分
96
价值分
46
活跃状态
活跃

README

SolarCalculator Library for Arduino

SolarCalculator is inspired by the NOAA Solar Calculator.

This library provides functions to calculate the times of sunrise, sunset, solar noon, twilight (dawn and dusk), Sun’s apparent position in the sky, equation of time, etc.

Most formulae are taken from Astronomical Algorithms by Jean Meeus and optimized for Arduino.

Installation

Download and copy SolarCalculator to your local Arduino/libraries directory.

Time

Date and time inputs are assumed to be in Universal Coordinated Time (UTC).

Although not required, it is recommended to use SolarCalculator along with the Time library or similar.

Usage

Include SolarCalculator.h in your sketch:

#include <SolarCalculator.h>

Calculate the times of sunrise, transit (solar noon), and sunset, in hours:

double latitude = 42.36;     // Observer's latitude 
double longitude = -71.058;  // Observer's longitude
int time_zone = -5;          // UTC offset
int year = 2000;             // Calendar year (1901-2099)
int month = 1;               // Calendar month (1-12)
int day = 1;                 // Calendar day (1-31)

double transit, sunrise, sunset;
calcSunriseSunset(year, month, day, latitude, longitude, transit, sunrise, sunset);

Or, using the Time library (Unix time):

time_t utc = now();
calcSunriseSunset(utc, latitude, longitude, transit, sunrise, sunset);

Convert to local standard time:

double sunrise_local = sunrise + time_zone;
  • Refer to the example sketches for more on rounding and printing the results.

Similarly, calculate the times of dawn and dusk, in hours:

calcCivilDawnDusk(utc, latitude, longitude, transit, c_dawn, c_dusk);
calcNauticalDawnDusk(utc, latitude, longitude, transit, n_dawn, n_dusk);
calcAstronomicalDawnDusk(utc, latitude, longitude, transit, a_dawn, a_dusk);

Sun’s equatorial coordinates, in degrees and AUs:

calcEquatorialCoordinates(utc, rt_ascension, declination, radius_vector);

Sun’s horizontal coordinates, corrected for atmospheric refraction, in degrees:

calcHorizontalCoordinates(utc, latitude, longitude, azimuth, elevation);

Equation of time, in minutes of time:

calcEquationOfTime(utc, eq);

where the results are passed by reference.

Examples

The following example sketches are included in this library:

  • SunriseSunset: Calculate the times of sunrise, solar noon, and sunset for a given date and location.

  • SunriseSunsetAltitude: Calculate the rise and set times at a height above the level of the horizon.

  • SolarCalculatorTimeLib: Calculate the rise and set times, equation of time, and current solar coordinates.

  • SolarTrackingTimeLib: Monitor the Sun’s position in the sky for any location on Earth.

  • EquationOfTime: Plot the equation of time for a given year.

Notes

Accuracy

Various things to consider:

  • The amount of atmospheric refraction changes with air temperature, pressure, and the elevation of the observer. Therefore, sunrise and sunset times can only be accurate to the nearest minute (Meeus, 1998).

  • Assuming a purely elliptical motion of the Earth, solar coordinates have a “low accuracy” of 0.01° (Meeus, 1998). To this precision, we ignore nutation, delta T, and higher-order terms in the relevant expressions.

double vs float

Although this library internally uses type double instead of float, all expressions have been optimized to work with single precision floating-point arithmetic. On Arduino Uno, avr-libc substitutes and carries out the corresponding single precision operations.

Sunrise and sunset

The algorithm for finding the times of sunrise and sunset implemented in this library is valid for all latitudes between the Arctic and Antarctic circles (about ± 66.5°). Outside this range, a more general algorithm should be used but is not provided at this time.

References

ESRL Global Monitoring Laboratory (n.d.). NOAA Solar Calculator. https://gml.noaa.gov/grad/solcalc/

Meeus, J. (1998). Astronomical algorithms (2nd ed.). Willmann-Bell.

评论

暂无评论