MarScaper / ephemeris

Simple C++ library allowing to compute planet coordinates (equatorial and horizontal) with an Arduino Mega.
56 stars 13 forks source link

Phase of the Moon #9

Open paviad opened 2 months ago

paviad commented 2 months ago

Question - Is there a way using this library to determine the phase of the moon at a given time point?

Thanks!

Lebostein commented 1 month ago

Yes! I have the same question. I use for other projects in Python the library "PyEphem" to calculate sunrise, sunset and moon phase: https://rhodesmill.org/pyephem/

Calculating the moon phase (float between 0 and 1) there is very simple:

_import ephem moon = ephem.Moon() observer = ephem.Observer() observer.lat = '52.520008' observer.long = '13.404954' observer.date = ephem.now() moon.compute(observer) print(moon.moonphase)

Now for an ESP32 project I took a look at this library, which promises a similar range of functions. Sunrise and sunset work. But I haven't yet found out how to calculate the moon phase...