~upd~: Virtuabotixrtc.h Arduino Library

Serial.print("Date (MM/DD/YYYY): "); Serial.println(myRTC.getDateStr()); // Returns "04/30/2026"

Instead of hardcoding, you can set the time based on your computer's clock at compilation using __TIME__ and __DATE__ macros, but note this requires parsing strings—a more advanced technique. virtuabotixrtc.h arduino library

The library is one of the most popular, lightweight, and user-friendly libraries available for interfacing Arduino boards with Real-Time Clock (RTC) modules. It is specifically optimized for the widely used DS1302 RTC chip. Serial

Includes a backup battery slot (usually for a CR2032 or CR1220 battery) to maintain timekeeping when the main Arduino power is disconnected. Wiring the DS1302 RTC to an Arduino Includes a backup battery slot (usually for a

// Set time to 15:15:00 on Saturday, March 23, 2024 myRTC.setDS1302Time(00, 15, 15, 7, 23, 3, 2024);

// Open file and log dataFile = SD.open("datalog.txt", FILE_WRITE); if (dataFile) dataFile.print(myRTC.getDateStr()); dataFile.print(","); dataFile.print(myRTC.getTimeStr()); dataFile.print(","); dataFile.println(temperatureC); dataFile.close();