Virtuabotixrtc.h Arduino Library
It provides an extremely easy-to-use set of functions to read and write time, handle leap years, and manage calendar dates. Because it uses standard digital pin shifting rather than standard I2C, it allows you to connect a DS1302 chip to virtually any available pins on an Arduino board. 📌 Library Overview
Here is the standard wiring diagram:
void loop() // Nothing to do here
void setup() Serial.begin(9600); if (!SD.begin(10)) Serial.println("SD Card failed!"); return; virtuabotixrtc.h arduino library
In conjunction with a CR2032 coin cell battery, it ensures the RTC maintains time even when the Arduino is powered off.
By following the wiring diagrams, mastering updateTime() and setDS1302Time() , and applying the project examples above, you can add precise timekeeping to anything from a simple alarm clock to a complex agricultural data logger.
After uploading the code for the first time to set the time, comment out setDS1302Time() It provides an extremely easy-to-use set of functions
April 11, 2026 Library version referenced: 1.0.0 (as available in Arduino Library Manager)
The virtuabotixrtc.h library is a third-party Arduino library designed to interface with low-cost, serial Real-Time Clock (RTC) modules, most notably the chip. Unlike the more common I2C-based DS1307 or DS3231 RTCs, the DS1302 uses a 3-wire serial interface. This library simplifies communication, time setting, and reading of these specific RTC modules, making them accessible for Arduino projects where cost is a primary constraint and precise timekeeping is moderately important.
: It uses standard digital pins for communication (typically CLK, DAT, and RST) rather than the I2C protocol used by newer RTCs like the DS3231. Wiring & Initialization By following the wiring diagrams, mastering updateTime() and
// Print the date and time Serial.print("Date: "); Serial.print(myRTC.month); Serial.print("/"); Serial.print(myRTC.dayofmonth); Serial.print("/"); Serial.print(myRTC.year); Serial.print(" - Time: "); Serial.print(myRTC.hour); Serial.print(":"); Serial.print(myRTC.minute); Serial.print(":"); Serial.println(myRTC.second);
#include // Creation of the Real Time Clock Object (CLK, IO, CE) virtuabotixRTC myRTC(6, 7, 8); void setup() Serial.begin(9600); // Set the time: (seconds, minutes, hours, day of week, day of month, month, year) myRTC.setDS1302Time(00, 59, 23, 6, 10, 1, 2024); void loop() // Update internal variables myRTC.updateTime(); // Access elements directly Serial.print(myRTC.hours); Serial.print(":"); Serial.println(myRTC.minutes); delay(1000); Use code with caution. Copied to clipboard