Virtuabotixrtc.h Arduino Library

virtuabotixRTC.h library is a popular, user-friendly Arduino library designed specifically to interface with the DS1302 Real-Time Clock (RTC) module. It simplifies the process of setting, updating, and reading time data (seconds, minutes, hours, day, month, year) from the module using only three pins.

// Uncomment to set time (year offset: 25 = 2025) // myRTC.setDS1302Time(0, 49, 14, 4, 21, 4, 25); virtuabotixrtc.h arduino library

To use this library, connect your DS1302 RTC module to your Arduino following this common pin configuration (though you can change the digital pins in the code): DS1302 Pin Arduino Pin (Example) Description VCC 5V or 3.3V Power Supply GND CLK / SCLK Digital Pin 6 Serial Clock DAT / I/O Digital Pin 7 Serial Data RST / CE Digital Pin 8 Reset / Chip Enable 💻 Core Functions & Methods 1. The Constructor virtuabotixRTC

: The library is older and may not be found in the official Arduino Library Manager by default; it often requires manual installation from GitHub repositories Hardware Accuracy To use this library, connect your DS1302 RTC

void loop() DateTime dt = rtc.getDateTime(); Serial.print("Date: "); Serial.print(dt.date); Serial.print("/"); Serial.print(dt.month); Serial.print("/"); Serial.print(dt.year); Serial.print(" Time: "); Serial.print(dt.hour); Serial.print(":"); Serial.print(dt.minute); Serial.print(":"); Serial.println(dt.second); delay(1000);
Mobiele weergave