| DS1302 Module Pin | Connect to Arduino Pin | | :--- | :--- | | | 5V (or 3.3V, but 5V is typical) | | GND | GND | | CLK (Clock) | Digital Pin 4 | | DAT (Data) | Digital Pin 3 | | RST (Reset/Chip Select) | Digital Pin 2 |
Note: Always ensure a CR2032 or compatible coin-cell battery is inserted into the RTC module. Without it, the module will reset its time whenever the Arduino loses power. Library Installation Guide
The library is extremely small and doesn't require heavy dependencies, making it suitable for boards with limited memory like the ATtiny series. Arduino Forum Outdated Architecture: virtuabotixrtc.h arduino library
: (seconds, minutes, hours, day of week, day of month, month, year) .
| Feature | VirtuabotixRTC | RTClib (Adafruit) | DS1302RTC (by JChristensen) | | :--- | :--- | :--- | :--- | | | DS1302 (3-wire) | DS1307, DS3231, PCF8523 (I2C) | DS1302 only | | Ease of Use | Easy | Very Easy | Moderate | | Memory Usage | Low (~1.5KB) | Medium (~2.5KB) | Low | | Active Development | No (Stable, legacy) | Yes | No | | Best For | Legacy DS1302 modules | Modern projects needing accuracy | Minimalist DS1302 users | | DS1302 Module Pin | Connect to Arduino
If you see the error message virtuabotixRTC.h: No such file or directory when compiling, it is a strong indication that the library has not been installed correctly. In this case, simply repeat the steps above to ensure the library is properly added.
Most users ignore the 31 bytes of NV RAM on the DS1302. However, VirtuabotixRTC.h exposes this through writeRAM() and readRAM() . This RAM is separate from the time registers and retains data as long as backup power is supplied. Most users ignore the 31 bytes of NV RAM on the DS1302
// --- Different ways to display time ---
The real power of the Virtuabotix library is in data logging. Let's build a temperature logger that only records from 9 AM to 5 PM.
The DS1302 chip, which this library primarily supports, counts seconds, minutes, hours, date of the month, month, day of the week, and year with leap-year compensation valid up to the year 2100. It communicates via a simple 3-wire serial interface: I/O (Data Line) SCLK (Serial Clock) How to Install the virtuabotixRTC Library