Virtuabotixrtch Arduino Library Verified -
Wiring the DS1302 to your Arduino is straightforward. The library is flexible and allows you to choose any digital pins you wish. The table below shows a common wiring example:
Perfect match for the highly affordable DS1302 module. 🛠️ Hardware Requirements
If you want, I can:
// --- FOR FIRST-TIME SETUP --- // Set the date and time. Do this once, then comment/remove these lines. // Format: (seconds, minutes, hours, dayOfWeek, dayOfMonth, month, year) // dayOfWeek: 1 = Monday, 2 = Tuesday ... 7 = Sunday myRTC.setDS1302Time(00, 45, 16, 6, 22, 5, 2026); // --- ********** ---
: Add #include at the top of your sketch. Hardware Wiring virtuabotixrtch arduino library
You can manually install the library by downloading the source from repositories like the ArduinoRTClibrary on GitHub and placing it in your Arduino 2. Basic Setup Example
// Format: sec, min, hour, dayOfWeek, dayOfMonth, month, year myRTC.setDS1302Time(00, 30, 15, 4, 17, 4, 2026); Use code with caution. Copied to clipboard 3. Retrieve and Update Time Wiring the DS1302 to your Arduino is straightforward
You can find the virtuabotixRTC.h file on GitHub. Add to Arduino IDE: Download the ZIP file from GitHub.
void loop() // Update the time variables from the RTC module myRTC.updateTime(); 🛠️ Hardware Requirements If you want, I can:
// *** IMPORTANT: Uncomment the line below to initially set the time *** // Format: seconds, minutes, hours, dayOfWeek, dayOfMonth, month, year // myRTC.setDS1302Time(0, 15, 14, 4, 13, 10, 2023); // *** After uploading this sketch, comment out the above line and upload again ***
You might notice that your RTC module always shows a default date/time (like 2000/01/01) when it powers up, instead of the time you set.