Virtuabotixrtc.h Arduino Library -

You only need to set the RTC once. This function sets the current date and time in your sketch's setup() function. Its format is: myRTC.setDS1302Time(seconds, minutes, hours, day_of_week, day_of_month, month, year); .

Real-time tracking is essential for Arduino projects like data loggers, automated feeding systems, and smart clocks. The virtuabotixrtc.h library provides a straightforward interface to control popular, budget-friendly Real-Time Clock (RTC) modules. 🛠️ Supported Hardware virtuabotixrtc.h arduino library

. This is usually called once in setup() to calibrate the clock. updateTime() You only need to set the RTC once

An RTC is an electronic device that keeps track of the current time even when the main microcontroller (like an Arduino) is powered off. It achieves this by utilizing a small backup battery (usually a CR2032 coin cell). Real-time tracking is essential for Arduino projects like

If you need more features (alarms, DST helpers, broader chip support), consider libraries such as RTClib (Adafruit) or TimeLib, which provide richer functionality and wider device support.

#include // // Declare the RTC object hooked up to pins 6, 7, and 8 virtuabotixRTC myRTC(6, 7, 8); void setup() Serial.begin(9600); // Start serial communication // IMPORTANT: Set the initial time here. // Seconds, Minutes, Hours, Day of the week, Day of the month, Month, Year // Day of week: 1 = Sunday, 2 = Monday, etc. myRTC.setDS1302Time(00, 15, 20, 1, 27, 4, 2026); // Example: April 27, 2026 at 8:15 PM // Note: After running this once, comment out the line above and re-upload! void loop() // Update the variables with data from the RTC chip myRTC.updateTime(); // Print the date Serial.print("Date: "); Serial.print(myRTC.dayofmonth); Serial.print("/"); Serial.print(myRTC.month); Serial.print("/"); Serial.print(myRTC.year); Serial.print(" Use code with caution. Copied to clipboard 🛠 Troubleshooting & Errors