Virtuabotixrtc.h Arduino Library Fixed Today
void loop() // rtc.getTime() or equivalent returns struct with fields: second, minute, hour, day, date, month, year // use fields to display or compute
The library is designed for ease of use, featuring a simple API to interact with the DS1302 module.
The library is highly optimized, leaving plenty of room for the rest of your project code. virtuabotixrtc.h arduino library
| | Arduino Pin | | :--- | :--- | | VCC | 5V | | GND | GND | | CLK (Serial Clock) | 6 (or any digital pin) | | DAT (I/O / Data) | 7 (or any digital pin) | | RST (Reset / CE) | 8 (or any digital pin) |
Download the library source ZIP file from a trusted repository. Open the Arduino IDE. Navigate to -> Include Library -> Add .ZIP Library . Select the downloaded file to install it. 2. Complete Code Example void loop() // rtc
void setup() Serial.begin(9600); // Uncomment to set time (year, month, date, hour, minute, second, dayOfWeek) // myRTC.setDS1302Time(0, 27, 13, 4, 11, 4, 2026); // Example: 2026-04-11 13:27:00 Sat
Works on any digital, PWM, or analog pin mapping on the Arduino. Open the Arduino IDE
To use the library, you must first define your hardware connections and create a clock object.
This minimal sketch reads the time from the RTC once per second and prints it to the Arduino's Serial Monitor, a classic way to confirm everything is working.