Virtuabotixrtc.h Arduino Library [new] Today
Arduino boards have internal timers, but they are not built for accurate, long-term timekeeping. They reset every time the board loses power, and their timing drifts significantly over days or weeks.
This minimal sketch reads the time from the RTC once per second and prints it to the Arduino's Serial Monitor, a classic way to confirm everything is working. virtuabotixrtc.h arduino library
#include <virtuabotixRTC.h> virtuabotixRTC myRTC(2, 3, 4); Arduino boards have internal timers, but they are
void setup() // Format: setDS1302Time(seconds, minutes, hours, dayOfWeek, dayOfMonth, month, year) // For example, to set the time to 3:28:15 PM on Tuesday, May 19th, 2026: myRTC.setDS1302Time(15, 28, 15, 2, 19, 5, 2026); #include <virtuabotixRTC
// Check if we are within working hours (9 AM to 5 PM) if (myRTC.hours >= 9 && myRTC.hours < 17)
This project logs temperature (from a TMP36 sensor) to an SD card alongside the current time.
// Define your pins: (RST, DAT, CLK) int RTC_RST = 2; int RTC_DAT = 3; int RTC_CLK = 4;