Virtuabotixrtc.h Arduino Library [new] Jun 2026

void loop() // Your main code here

The DS1302 module has a small silver coin cell battery slot (usually a CR2032). If your clock is losing time when the Arduino is unplugged, check or replace this battery.

void setup() Serial.begin(9600); // Set the time/date once. // Format: seconds, minutes, hours, dayOfWeek, dayOfMonth, month, year myRTC.setDS1302Time(0, 51, 14, 3, 22, 6, 2026); // After setting, comment out or remove this line.

The virtuabotixRTC.h library is a fantastic tool for any Arduino enthusiast looking to add timekeeping to their projects. Its simplicity is its greatest strength, providing a clear and effective pathway to get a DS1302-based RTC module running in minutes. virtuabotixrtc.h arduino library

The library's constructor requires you to specify the three Arduino pins connected to the DS1302 module: virtuabotixRTC myRTC(CLK_PIN, DAT_PIN, RST_PIN); . While the order can vary, a common wiring scheme found in many examples is:

By following this guide, you now understand:

void loop() (hour == 8 && minute <= 59)) digitalWrite(ledPinRed, LOW); digitalWrite(ledPinGreen, HIGH); void loop() // Your main code here The

: Manages seconds, minutes, and hours (including 24-hour or AM/PM formats).

The pin naming can vary. Some modules use SCLK , I/O , and CE instead of CLK , DAT , and RST . No matter the name, the function is the same.

virtuabotixRTC myRTC(6, 7, 8); const int ledPinRed = 13; const int ledPinGreen = 12; The library's constructor requires you to specify the

This function is used to set the current time and date on the DS1302 chip. It is typically used only once in the setup() function. Once the module is set, it will continue counting independently.

A standard implementation for reading time every second looks as follows:

module. Unlike some advanced libraries, it focuses on a simple, user-friendly implementation of time-setting and retrieval. Arduino Project Hub Key Features Minimal Interface: