The VirtuabotixRTC library is a popular, lightweight Arduino library designed to interface with Real Time Clock (RTC) modules, specifically the DS1302, DS1307, and DS3231 chips. While similar to other RTC libraries, VirtuabotixRTC is favored for its simplicity and its streamlined method for setting the time and date inside the setup() loop.

Once myRTC.updateTime() is called, you can access the following public variables:

Unlike the more common DS3231 or PCF8523 modules which use I2C, the DS1302 chip relies on a proprietary 3-pin serial interface. The VirtuabotixRTC.h library (originally created by Virtuabotix) abstracts this communication into simple, readable C++ commands.

Key Features:


This is the most distinct feature of this library. To set the time, you pass the current date and time parameters directly to the setDS1302Time function inside setup().

Note: You should upload the code once to set the time, then comment out the setDS1302Time line and upload the code again to prevent the Arduino from resetting the time to the compiled moment every time it resets.

void setup() 
  Serial.begin(9600);
// Format: seconds, minutes, hours, day of week, day of month, month, year
  // Example: Setting time to Oct 25, 2023, Wednesday, 14:30:00
  // Day of week: 1=Sunday, 2=Monday, ... 7=Saturday
// UNCOMMENT THE NEXT LINE TO SET TIME, THEN COMMENT IT BACK AND RE-UPLOAD
  // myRTC.setDS1302Time(00, 30, 14, 4, 25, 10, 2023);

The Virtuabotix RTC modules typically communicate via a 3-wire serial interface (I/O, SCLK, CE/RST) for the DS1302, or I2C for the DS1307/DS3231.

Note: The library code usually defaults to the pin connections defined in the constructor. If you are using a standard Virtuabotix breakout board, connect the pins as follows:

Virtuabotixrtc.h Arduino Library

The VirtuabotixRTC library is a popular, lightweight Arduino library designed to interface with Real Time Clock (RTC) modules, specifically the DS1302, DS1307, and DS3231 chips. While similar to other RTC libraries, VirtuabotixRTC is favored for its simplicity and its streamlined method for setting the time and date inside the setup() loop.

Once myRTC.updateTime() is called, you can access the following public variables:

Unlike the more common DS3231 or PCF8523 modules which use I2C, the DS1302 chip relies on a proprietary 3-pin serial interface. The VirtuabotixRTC.h library (originally created by Virtuabotix) abstracts this communication into simple, readable C++ commands. virtuabotixrtc.h arduino library

Key Features:


This is the most distinct feature of this library. To set the time, you pass the current date and time parameters directly to the setDS1302Time function inside setup(). The VirtuabotixRTC library is a popular, lightweight Arduino

Note: You should upload the code once to set the time, then comment out the setDS1302Time line and upload the code again to prevent the Arduino from resetting the time to the compiled moment every time it resets.

void setup() 
  Serial.begin(9600);
// Format: seconds, minutes, hours, day of week, day of month, month, year
  // Example: Setting time to Oct 25, 2023, Wednesday, 14:30:00
  // Day of week: 1=Sunday, 2=Monday, ... 7=Saturday
// UNCOMMENT THE NEXT LINE TO SET TIME, THEN COMMENT IT BACK AND RE-UPLOAD
  // myRTC.setDS1302Time(00, 30, 14, 4, 25, 10, 2023);

The Virtuabotix RTC modules typically communicate via a 3-wire serial interface (I/O, SCLK, CE/RST) for the DS1302, or I2C for the DS1307/DS3231. This is the most distinct feature of this library

Note: The library code usually defaults to the pin connections defined in the constructor. If you are using a standard Virtuabotix breakout board, connect the pins as follows: