Arduino Library - Virtuabotixrtc.h
: The primary hardware target for this library.
After uploading the code for the first time to set the time, comment out setDS1302Time()
Note: exact function names may vary slightly between versions; check the library header for the precise signatures. virtuabotixrtc.h arduino library
delay( // Wait one second Use code with caution. Copied to clipboard Tips for Success Installation: Download the ArduinoRTClibrary and install it via Sketch > Include Library > Add .ZIP Library in the Arduino IDE. Prevent Resets:
Most users ignore the 31 bytes of NV RAM on the DS1302. However, VirtuabotixRTC.h exposes this through writeRAM() and readRAM() . This RAM is separate from the time registers and retains data as long as backup power is supplied. : The primary hardware target for this library
Now, let's put this all together with a practical project: a digital clock that displays the time and date on a 16x2 LCD screen. This will combine the RTC module, the VirtuabotixRTC library, and an LCD.
An Arduino does not keep track of time (hours, minutes, seconds) accurately once powered off. A Real Time Clock module, powered by a small coin cell battery, keeps ticking even when the Arduino is turned off. This library allows the Arduino to: Copied to clipboard Tips for Success Installation: Download
The virtuabotixRTC library is not included in the default Arduino IDE installation, so you will need to install it manually. While the library may not be readily available in the Library Manager, you can find its download on various Arduino tutorial websites.
// SET THE TIME ONCE, THEN COMMENT THIS LINE OUT OR IT WILL RESET EVERY TIME YOU REBOOT // Format: seconds, minutes, hours, day of week, day of month, month, year // Example: October 24, 2023, 14:30:00, Tuesday (Day of week is 1-7, Mon-Sun) // myRTC.setDS1302Time(00, 30, 14, 2, 24, 10, 23);
The library is a popular, lightweight Arduino library designed to interface with Real Time Clock (RTC) modules, specifically the DS1302 , DS1307 , and DS3231 chips. While similar to other RTC libraries, VirtuabotixRTC is favored for its simplicity and its streamlined method for setting the time and date inside the setup() loop.