Because the library provides a reliable way to track time, it's a natural component for more complex projects like a fingerprint-based attendance system. In such a system, when a successful fingerprint match occurs, the Arduino can fetch the exact date and time from the RTC via the VirtuabotixRTC library and log it to EEPROM or an SD card, creating an accurate record of the event.
The library works by creating an RTC object and using specific methods to manage time. 1. Initialize the Object Define your pins in the order: CLK , DAT , RST . virtuabotixRTC myRTC(6, 7, 8); Use code with caution. Copied to clipboard 2. Set the Time
This library is specifically designed for the chip (often sold in a module with a battery and crystal oscillator). Unlike the more common DS1307 (I2C) or DS3231, the DS1302 uses a 3-wire interface similar to SPI. virtuabotixrtch arduino library
// 2. Print to Serial Monitor Serial.print(myRTC.hours); Serial.print(":"); Serial.print(myRTC.minutes); Serial.print(":"); Serial.println(myRTC.seconds);
#include <virtuabotixRTC.h> // 1. Include the library Because the library provides a reliable way to
Note: Some modules label RST as "CE" (Chip Enable).
From a practical standpoint, the library operates like a streamlined driver: it translates high-level commands from your Arduino sketch (like reading the current hour) into the specific low-level commands the DS1302 understands, and vice-versa. Many online tutorials and projects refer to a ZIP file named virtuabotixRTC.zip as the original source, though it is now primarily known to be maintained and accessible through a popular GitHub repository hosted under chrisfryer78/ArduinoRTClibrary . Copied to clipboard 2
// Pin definition for Uno/Nano // (SDA, SCL) VirtuabotixRTC myRTC(A4, A5);
: Once updateTime() is called, you can directly query specific integers from the object, such as myRTC.seconds , myRTC.minutes , myRTC.hours , myRTC.dayofweek , myRTC.dayofmonth , myRTC.month , and myRTC.year . Wiring Guide: DS1302 to Arduino Uno