Moon Phase Calculator With OLED Display Using Arduino

Moon Phase Calculator with OLED Display (Last Updated On: February 22, 2019)

Moon Phase Calculator With OLED Display Using Arduino:

In this post we will discuss about How to make Moon Phase Calculator With OLED Display Using Arduino. This small project displays the moon phase on an 0.96″ OLED display. Eight phases are shown with a short description, the days remaining to the next full moon is also displayed.

This project uses a real time clock RTC Module DS3231 or DS1307 to provide the date. This date is converted into a Julian date. By choosing a date that had a known full moon, in this case 1st January 1972, the number of days from this starting point until now is easily calculated.

Why does the Moon have phases?

The Moon has phases because it orbits Earth, which causes the portion we see illuminated to change. The Moon takes 27.3 days to orbit Earth, but the lunar phase cycle (from new Moon to new Moon) is 29.5 days. The Moon spends the extra 2.2 days “catching up” because Earth travels about 45 million miles around the Sun during the time the Moon completes one orbit around Earth.

Moon Phase Calculator with OLED Display

At the new Moon phase, the Moon is so close to the Sun in the sky that none of the side facing Earth is illuminated (position 1 in illustration). In other words, the Moon is between Earth and Sun. At first quarter, the half-lit Moon is highest in the sky at sunset, then sets about six hours later (3). At full Moon, the Moon is behind Earth in space with respect to the Sun. As the Sun sets, the Moon rises with the side that faces Earth fully exposed to sunlight (5).

Components Required:

1. 0.96″ OLED Display – (Buy Online From Amazon)
2. Arduino UNO Board
3. RTC Module DS3231 or DS1307 – (Buy Online From Amazon)
4. Breadboard
5. Jumper Wires

Circuit Diagram & Connections:

Moon Phase Calculator with OLED Display

Both the OLED and RTC Module DS3231 is powered by 5V power Supply. The SCL and SDA Pins of OLED & DS3231 is connected to SCL and SDA pins of Arduino, i.e A4 & A5.

Designing Moon Phase Calculator:

The moon takes 29.53 days to complete the cycle from one full moon to the next, so if we divide the number of days since 1st January 1972 by 29.53 the remainder will be the number of days in this lunar month so far.

Moon Phase Calculator with OLED Display

The sketch divides the lunar month into eight parts, starting with a full moon then waning gibbous, last quarter, crescent old, new moon, crescent new, first quarter , waxing gibbous and back to a full moon. The number of days to the next full month is also shown.

Results & Display:

Once the code is uploaded to Arduino UNO board for Moon Phase Calculator With OLED Display Using Arduino, the moon phase will be shown and also the day will be displayed as 1, 2, 3, 4 ……..28 as shown in the figure below.

Source Code/Program:

First add the two library, i.e U8glib Library & RTC Library else the code won’t compile.

  1. Download U8glib Library
  2. Download RTClib Library

Video Demonstration:

Recommended For You

About the Author: Alex Newton

Ask A Question .......