The VirtuabotixRTC.h Arduino library is a popular and widely-used library for working with Real-Time Clocks (RTCs) in Arduino projects. Developed by Virtuabotix, a well-known brand in the electronics industry, this library provides an easy-to-use interface for communicating with RTC modules, enabling accurate time-keeping and date-tracking capabilities in Arduino-based projects.
The library is a dedicated tool for the Arduino platform, designed to simplify communication with the DS1302 Real-Time Clock (RTC) chip . By providing a streamlined interface for timekeeping, it enables makers to integrate precise date and time tracking into their electronic projects with minimal code. The Role of the DS1302 RTC
void setup() Serial.begin(9600); Wire.begin(); myRTC.setTime(14, 30, 0); // 14:30:00 myRTC.setDate(3, 15, 4, 26); // Tuesday, 15 April 2026 (example format)
delay(1000); // Wait 1 second before reading again
Many modern RTC modules use the DS1307 or DS3231 chips, which communicate via the I2C protocol. However, the DS1302 chip uses a 3-wire serial interface.
void setup() Serial.begin(9600); // Set the time/date once. // Format: seconds, minutes, hours, dayOfWeek, dayOfMonth, month, year myRTC.setDS1302Time(0, 51, 14, 3, 22, 6, 2026); // After setting, comment out or remove this line.
setDS1302Time(seconds, minutes, hours, dayofWeek, dayofMonth, month, year) — Writes new time parameters to the chip.