Library: Virtuabotixrtc.h Arduino
void loop() // Nothing here – this is a one‑time setup
Choose VirtuabotixRTC when you want to keep I2C free or are using a DS1302 module you already own. The VirtuabotixRTC library is a reliable, lightweight way to add timekeeping to your Arduino projects. Its straightforward functions and flexible pin assignment make it perfect for beginners and pros alike. Whether you’re building an automatic plant waterer, a data logger, or a programmable timer, this library has you covered.
| DS1302 Pin | Arduino Pin | |------------|--------------| | VCC | 5V | | GND | GND | | CLK | 6 | | DAT | 7 | | RST | 8 | virtuabotixrtc.h arduino library
// Set the time (year, month, day, hour, minute, second, day-of-week) // Sunday = 1, Monday = 2, ..., Saturday = 7 // Example: March 15, 2025, 14:30:00, Saturday = 7 myRTC.setDS1302Time(25, 3, 15, 14, 30, 00, 7);
void setup() pinMode(ledPin, OUTPUT); Serial.begin(9600); void loop() // Nothing here – this is
void setup() Serial.begin(9600);
After running this, comment out myRTC.setDS1302Time(...) or upload a new sketch that only reads time. Example 2: Reading the Current Time Here’s the most common use: continuously reading the RTC and printing to Serial Monitor. Whether you’re building an automatic plant waterer, a
void loop() // Update the internal variables from the RTC chip myRTC.updateTime();
delay(1000); // Update every second
If you’ve ever built an Arduino project that involves logging data, controlling lights on a schedule, or waking up a device at a specific time, you know that keeping accurate time is crucial. While the popular RTClib works great for DS3231 and DS1307 modules, there’s another powerful—and often overlooked—option: the VirtuabotixRTC.h library.