Virtuabotixrtc.h Arduino Library | No Login
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.
Serial.println("Time set on RTC.");
// Turn LED on between 8:00 and 19:59 (8 AM to 7:59 PM) if (currentHour >= 8 && currentHour < 20) digitalWrite(ledPin, HIGH); if (currentHour == 8 && myRTC.minutes == 0 && myRTC.seconds < 5) Serial.println("Good morning! LED is ON."); virtuabotixrtc.h arduino library
#include <VirtuabotixRTC.h> VirtuabotixRTC myRTC(6, 7, 8);
int currentHour = myRTC.hours;
// Print the time Serial.print(" – Time: "); Serial.print(myRTC.hours); Serial.print(":"); Serial.print(myRTC.minutes); Serial.print(":"); Serial.println(myRTC.seconds);
void setup() pinMode(ledPin, OUTPUT); Serial.begin(9600); If you’ve ever built an Arduino project that
// 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);
In this post, we’ll dive deep into what makes this library special, how to install it, and walk through practical examples to get your Real Time Clock (RTC) running in minutes. The VirtuabotixRTC library is designed specifically for the DS1302 real-time clock chip. Unlike the more common DS1307 or DS3231 (which use I2C), the DS1302 communicates via a 3-wire interface (CLK, DAT, RST). This makes it incredibly simple to wire up and frees your I2C pins for other sensors. LED is ON
Open the Serial Monitor (9600 baud) and watch the live clock. This is where the RTC shines. Let’s turn an LED on at 8:00 AM and off at 8:00 PM.
delay(1000); // Update every second