https://github.com/celliesprojects/moonphase-esp32
An ESP32 library to get the moon phase angle and visible percentage of the moon that is illuminated.
https://github.com/celliesprojects/moonphase-esp32
arduino-ide esp32-arduino lunar-phase moon moon-phase moon-phase-angle
Last synced: about 1 month ago
JSON representation
An ESP32 library to get the moon phase angle and visible percentage of the moon that is illuminated.
- Host: GitHub
- URL: https://github.com/celliesprojects/moonphase-esp32
- Owner: CelliesProjects
- License: mit
- Created: 2018-04-29T14:47:34.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-10-25T16:24:51.000Z (7 months ago)
- Last Synced: 2025-04-16T06:59:38.088Z (about 1 month ago)
- Topics: arduino-ide, esp32-arduino, lunar-phase, moon, moon-phase, moon-phase-angle
- Language: C++
- Homepage:
- Size: 207 KB
- Stars: 30
- Watchers: 1
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
### moonPhase
A library for esp32 to get the moon phase angle and percentage of the moon that is illuminated. (as seen from Earth)
Preferred methods to install is to use the Arduino IDE library manager.For esp8266 non-os or avr (Arduino) you can use the [steve-sienk fork](https://github.com/steve-sienk/moonPhaser-avr).
#### Manual install
1. Download the latest release and unpack in the Arduino `libraries` folder.
2. Restart the Arduino IDE.#### Functions
- `getPhase()` Get the current moon phase. (First set freeRTOS system time - see the esp32-sntp example)
- `getPhase( time_t t )` Get the moon phase as it was at time `t`.
#### Example code
```c++
#includemoonPhase moonPhase; // include a MoonPhase instance
void setup() {
Serial.begin(115200);
Serial.println();
Serial.println( "moonPhase simple example." );moonData_t moon; // variable to receive the data
moon = moonPhase.getPhase(); // gets the current moon phase ( 1/1/1970 at 00:00:00 UTC )
Serial.print( "Moon phase angle: " );
Serial.print( moon.angle ); // angle is a integer between 0-360
Serial.println( " degrees." );
Serial.print( "Moon surface lit: " );
Serial.print( moon.percentLit * 100 ); // percentLit is a real between 0-1
}void loop() {
// put your main code here, to run repeatedly:}
```