Virtuabotixrtc.h Arduino | Library Verified
A Real-Time Clock (RTC) is a type of electronic component that keeps track of time and date, even when the main power source is turned off. RTCs are commonly used in applications where accurate time-keeping is crucial, such as in digital clocks, calendars, and data loggers.
Are you planning to display the time on an or log it to an SD card ?
// LCD pin mapping (RS, E, D4, D5, D6, D7) LiquidCrystal lcd(12, 11, 5, 4, 3, 2); virtuabotixrtc.h arduino library
Automatically formatting time variables (seconds, minutes, hours, day of the week, day of the month, month, and year). Hardware Wiring: Connecting DS1302 to Arduino
: Typically includes VCC, GND, CLK (Clock), DAT (Data), and RST (Reset) pins. A Real-Time Clock (RTC) is a type of
The VirtuabotixRTC library is not available through the default Arduino Library Manager. You must manually install it from a ZIP file.
| Function | Syntax Example | Description | | :--- | :--- | :--- | | | VirtuabotixRTC(int clk, int dat, int rst) | Initializes the library with the three Arduino pins connected to the DS1302's CLK, DAT (I/O), and RST (CE) pins. | | updateTime() | rtc.updateTime(); | Reads the current time from the RTC chip and stores it in the object's internal variables. Must be called before reading time. | | setDS1302Time() | rtc.setDS1302Time(seconds, minutes, hours, dayOfWeek, date, month, year); | Writes a new time/date to the RTC chip. Typically called once during setup. | | Accessing Time | rtc.hours , rtc.minutes , rtc.seconds , rtc.dayofmonth , rtc.month , rtc.year , rtc.dayofweek | After updateTime() , these integer variables hold the current time components. | // LCD pin mapping (RS, E, D4, D5,
library was created to act as the ultimate bridge. Before it arrived, programmers had to manually toggle pins and calculate binary codes just to find out if it was Tuesday. But with this library, everything changed. All a maker had to do was call its name at the start of their code: #include Setting the Clock's Heartbeat
| DS1302 Pin | Arduino Pin | Description | | :--- | :--- | :--- | | | 5V | Power | | GND | GND | Ground | | CE / RST | Digital Pin 2 | Chip Enable / Reset | | I/O / DAT | Digital Pin 3 | Data Input/Output | | SCLK | Digital Pin 4 | Serial Clock |