Virtuabotixrtc.h Arduino Library 🎯 Must See
// 3. Combined Serial.print("Full Stamp: "); Serial.print(myRTC.getDateStr()); Serial.print(" "); Serial.println(myRTC.getTimeStr());
Once updateTime() is called, the library provides direct access to time components via public members of the object: myRTC.seconds myRTC.minutes myRTC.hours myRTC.dayofmonth myRTC.month myRTC.year myRTC.dayofweek Example Implementation virtuabotixrtc.h arduino library
#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 | DS1302 Module Pin | Connect to Arduino
Once the time is updated via the updateTime() method, users can access individual variables like myRTC.hours or myRTC.year as standard integers. // Example: April 27
| DS1302 Module Pin | Connect to Arduino Pin | | :--- | :--- | | | 5V (or 3.3V, but 5V is typical) | | GND | GND | | CLK (Clock) | Digital Pin 4 | | DAT (Data) | Digital Pin 3 | | RST (Reset/Chip Select) | Digital Pin 2 |