Virtuabotixrtc.h Arduino Library -

While the official Arduino RTC library exists, the Virtuabotix version gained popularity because of its simplicity and its ability to handle the quirky timing protocols of the DS1302. The library handles the low-level bit-banging necessary to read and write time data, allowing you to use simple commands like rtc.getTimeStr() or rtc.setDate() .

setDS1302Time(seconds, minutes, hours, dayofWeek, dayofMonth, month, year) — Writes new time parameters to the chip.

Download the library source files (ZIP format) from a trusted repository like GitHub. Open your Arduino IDE.

This project logs temperature (from a TMP36 sensor) to an SD card alongside the current time. virtuabotixrtc.h arduino library

Uses a simple 3-wire setup (Clock, Data, and Reset/Enable).

: It allows users to define which Arduino pins are connected to the DS1302’s Data (DAT), Clock (CLK), and Reset (RST) pins through a simple object constructor, such as virtuabotixRTC myRTC(clk, dat, rst) .

delay(1000); // Wait 1 second before reading again While the official Arduino RTC library exists, the

Combine the RTC with a 16x2 I2C LCD for a stand-alone desk clock.

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.

myRTC.writeRegister(0x80, 0x00); // Write 0 to seconds register (clears CH) Download the library source files (ZIP format) from

The library simplifies communication with the DS1302 by managing the specific bit-banging protocol required for its data transfer. Its primary class, virtuabotixRTC , exposes several key methods:

Originally written and released by the Virtuabotix team (now maintained in legacy and community forms), this library provides a lightweight, straightforward interface to read and write time data from the DS1302 via a simple 3-wire interface. Unlike its I2C-based cousins, the DS1302 uses a proprietary synchronous serial protocol that this library handles natively.

Go to File > Examples . You should see a folder named VirtuabotixRTC .