Virtuabotixrtch Arduino Library (2026)
Allows developers to set the current time and date with a single line of code.
If the time resets to your initial code settings every time you power on, ensure you commented out the setDS1302Time line after the first successful run.
The library makes connecting the DS1302 to your Arduino straightforward, as it uses simple digital pins and is not reliant on more complex communication protocols like I2C.
In the Arduino IDE, go to Sketch -> Include Library -> Add .ZIP Library... and select the downloaded file. virtuabotixrtch arduino library
// setDS1302Time(seconds, minutes, hours, dayofweek, dayofmonth, month, year) myRTC.setDS1302Time(00, 30, 14, 2, 26, 5, 2026); Use code with caution. 3. Reading the Time
A slightly older model that requires a specific 3-wire communication interface but is very budget-friendly. How to Install the Library
Download the library source files (ZIP format) from a trusted repository. Open the Arduino IDE. Allows developers to set the current time and
If you are using the standard Virtuabotix DS1302 module, it typically requires a 3-wire interface (I2C is not used for the DS1302; it uses a serial protocol).
Note: While pins 6, 7, and 8 are commonly used in tutorial examples, you can assign the CLK, DAT, and RST lines to any digital pins on your Arduino. Installation Guide
Do not put setTime() inside loop() . It will reset your clock to the compile time repeatedly, making the clock appear frozen. In the Arduino IDE, go to Sketch -> Include Library -> Add
At the heart of the VirtuabotixRTC library is the itself. While the Arduino has an internal timer (the millis() function), it's not a true real-time clock. The Arduino's timer stops counting when power is removed or the board is reset, and it's not designed for keeping accurate track of calendar days, months, and years.
The library stores years as two-digit (0 to 99). You must manually add 2000 in your print statement: