/moon_phase_calculator

A simple algorithm to calculate Moon's Phase on a given date using the Arduino environment. Here, I used the Heltec esp32 v2 development board.

Primary LanguageC

Moon Phase Calculator

Contents


General Info


This is a simple algorithm to calculate Moon's Phase on a given date using the Arduino environment. Here, I used the Heltec esp32 v2 development board.
The algorithm is inspired by the magazine skyandtelescope.
You can find also a previous version using an Arduino nano and a Nokia LCD display in my old Github account.

Usage


The main function is moonPhases(int year, int month, int day) where 'year' is a four-digit number.

/* Calculate the moon number */
moonNum = moonPhases(year, month, day);

moonNum corresponds to the "moon day/age", as well as the bitmap image number to be drawn on the OLED display.
A Time zone is also needed for the calculation of the Julian day :

int timeZone = 2;

Test


Make sure to install the fellowing dependencies before you run the program:

Here is an output example of the following inputs :

int timeZone = 2;
int day = 17;
int month = 8;
int year = 2021;

Image text

Useful link and References


Todo

  • Add an example using NTP server to get the current date