Virtuabotixrtc.h Arduino Library Site
// SET THE TIME ON THE RTC (RUN ONCE) // Set to: 0 seconds, 30 minutes, 14 hours, Sunday (1), 7th day, April (4), 2024 // myRTC.setDS1302Time(0, 30, 14, 1, 7, 4, 2024); // Comment this line after you set the time.
A Real-Time Clock (RTC) is a type of electronic component that keeps track of time and date, even when the main power source is turned off. RTCs are commonly used in applications where accurate time-keeping is crucial, such as in digital clocks, calendars, and data loggers.
To understand the library, one must first understand the hardware it drives. The DS1302 is a trickle-charge timekeeping chip manufactured by Maxim Integrated (now Analog Devices). Key features include: virtuabotixrtc.h arduino library
#include <VirtuabotixRTC.h>
The pin naming can vary. Some modules use SCLK , I/O , and CE instead of CLK , DAT , and RST . No matter the name, the function is the same. // SET THE TIME ON THE RTC (RUN
| Library | RTC Chip | Interface | Features | |---------|----------|-----------|----------| | VirtuabotixRTC.h | DS1302 | 3-wire bitbang | Simple, NV RAM | | RTClib (Adafruit) | DS1307, PCF8523, DS3231 | I2C | Leap year, temperature, alarms | | DS1302 (Arduino playground) | DS1302 | 3-wire | Lightweight, no RAM support |
The library revolves around two key actions: updateTime() and setDS1302Time() . To understand the library, one must first understand
Automatically accounts for leap years up to the year 2100. 🔌 Hardware Wiring (DS1302 to Arduino)
int alarmHour = 7; int alarmMinute = 0;
VirtuabotixRTC rtc(5, 4); // SCL pin 5, SDA pin 4