Virtuabotixrtc.h Arduino Library Jun 2026
If the RTC resets to its default time every time the Arduino loses power, the backup battery is likely not installed, dead, or incorrectly inserted. The DS1302 requires a valid CR2032 battery to maintain timekeeping when main power is removed. Check the battery and its holder.
// Define your pins: (RST, DAT, CLK) int RTC_RST = 2; int RTC_DAT = 3; int RTC_CLK = 4;
// 1. Raw integers (Best for logic) Serial.print("Raw Data: "); Serial.print(myRTC.hours); // 24-hour format Serial.print(":"); Serial.print(myRTC.minutes); Serial.print(":"); Serial.println(myRTC.seconds); virtuabotixrtc.h arduino library
#include // Pins used: CLK, DAT, RST virtuabotixRTC myRTC(6, 7, 8); Use code with caution. Copied to clipboard
void setup() Serial.begin(9600);
The virtuabotixRTC.h library is a widely used Arduino library specifically designed to interface with the . It provides a simple, high-level wrapper around the DS1302’s complex three-wire serial communication protocols. Core Functionality
delay(500);
The library provides two pathways:
// Pin connections: (SCLK, I/O, CE) VirtuabotixRTC myRTC(6, 7, 8); If the RTC resets to its default time