: The updateTime() function must be called within the loop() to refresh the local variables before reading them. Basic Code Structure A standard implementation typically follows this pattern:
The library uses minimal flash memory, leaving room for complex project logic.
After calling myRTC.updateTime() , you can access the time data using the following member variables: virtuabotixrtc.h arduino library
Unlike the more modern RTClib by Adafruit (which is excellent for DS3231 and DS1307 over I2C), the Virtuabotix library handles the unique to the DS1302. This is crucial because the DS1302 uses a different communication method than standard I2C or SPI devices.
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: : The updateTime() function must be called within
: Manages seconds, minutes, and hours (including 24-hour or AM/PM formats).
The DS1302 uses a 3-wire synchronous serial interface. You can connect it to any three digital pins on your Arduino, but common practice uses pins 2, 3, and 4. This is crucial because the DS1302 uses a
#include <virtuabotixRTC.h>
By following this guide, you now understand: