Some Arduino projects may improve its functionality by calculating sunrise and sunsets times or current moon age. You can create the weather station or animated clock that starts an animation in the morning and stops it at sunset time. There was one software library for Arduino on the Internet that could calculate some astronomical events, but actually it is not compatible with the current Arduino IDE version and the Time library, which is very convenient to manipulate the time in Arduino sketches. The new sun-moon library can help you create such a interesting project.
Let's build simple schematics on the breadboard.The component list is very short, you can use any Arduino board you like: Nano or Uno, the breadboard and wires. The most valuable component of this project is a real time clock module. The DS3231 module has a high accuracy and uses only two wires to connect to the Arduino through the I2C bus.
The data sheet of DS3231 module states that the module requires power supply of 5V. In this case you should use the backup accumulator LIR2032 which is not widely available and expensive. In any hand, the clock module is proven to work at 3.3v and in this case you can use the battery CR2032 for backup.
Do not put CR2032 battery in to the clock module in case of using 5V power supply, the battery can be damaged.
The sunMoon
class of the software library has the following methods:
julianDay
- return Julian day number for the time specified or for the current time if no argument specified;
sunRise
andsunSet
functions return the time of sunrise and sunset of the current day or the day specified by the time argument;
moonDay
- return the moon age in the days;
The sketch gives the handful example of using these functions.
Hope this library helps you build creative projects.
Comments