Because the virtuabotixRTC library is a community-developed tool, it may not always appear in the official Arduino IDE Library Manager. You can install it manually using these steps:
The most common mistake beginners make is leaving the setDS1302Time() function inside the setup() loop permanently. Every time you power cycle or reset the Arduino, the time will go back to the hardcoded time. Set the time once, then comment out that line and re-upload.
void setup() rtc.setDateTime(2022, 7, 25, 10, 30, 0); virtuabotixrtc.h arduino library
The virtuabotixRTC.h library serves as the software bridge between the Arduino and this hardware. Its primary functions include:
Use VirtuabotixRTC if you already have a DS1302 module and need a 5-minute setup. Use RTClib for long-term, high-accuracy projects. Set the time once, then comment out that line and re-upload
void setup() pinMode(ledPinRed, OUTPUT); pinMode(ledPinGreen, OUTPUT); // myRTC.setDS1302Time(0, 28, 15, 2, 19, 5, 2026); // Set initial time
If your Arduino project needs to track the exact time—even after losing power—you need a Real-Time Clock (RTC) module. The DS1302 is a highly popular, low-cost RTC chip used for this exact purpose. To make this chip talk to your microcontroller easily, developers rely on the library. Use RTClib for long-term, high-accuracy projects
Real-time tracking is essential for Arduino projects like data loggers, automated feeding systems, and smart clocks. The virtuabotixrtc.h library provides a straightforward interface to control popular, budget-friendly Real-Time Clock (RTC) modules. 🛠️ Supported Hardware