Virtuabotixrtch Arduino Library Here

void loop() // Nothing to do here during the setup phase

The library's simplicity makes it a favorite for a wide array of projects. Here are some common examples found in the community:

lcd.setCursor(0, 1); lcd.print(myRTC.month); lcd.print("/"); lcd.print(myRTC.dayofmonth); lcd.print("/20"); lcd.print(myRTC.year);

If your Arduino resets and the time goes back to a default date (like 2000), the coin cell battery (CR2032) on the RTC module is likely dead or missing. Replace the battery to ensure the module keeps time while the Arduino is powered off. virtuabotixrtch arduino library

// Set time: (second, minute, hour, dayOfWeek, date, month, year) // Example: 15:30:45 on Sunday, March 12, 2025 // Note: Day of week: 1=Sun, 2=Mon, 3=Tue, 4=Wed, 5=Thu, 6=Fri, 7=Sat myRTC.setDS1302Time(45, 30, 15, 1, 12, 3, 25);

Before programming, you must connect the five physical pins of the DS1302 breakout board to your Arduino. While you can use almost any digital pins, the standard layout used in community examples is outlined below: DS1302 Pin Arduino Pin Description 5V or 3.3V Primary Power Supply GND Ground Reference CLK / SCLK Digital Pin 6 Serial Clock Line DAT / IO Digital Pin 7 Bi-directional Data Line RST / CE Digital Pin 8 Chip Enable / Reset Pin Step-by-Step Code Implementation

The Arduino library is a specialized software tool designed to interface Arduino microcontrollers with Real-Time Clock (RTC) modules, most notably the highly popular DS1302 chip. Unlike standard Arduino internal timers, which reset every time the board loses power, an RTC keeps accurate time for years by running on a small backup coin-cell battery. void loop() // Nothing to do here during

After uploading, comment out or remove the setDS1302Time line and re-upload. Otherwise, it will reset the time every boot.

Serial.println("RTC time has been set!");

If you want, I can:

To use the library, you must first include the header and define the pins connected to your DS1302 module. Import a Code Library to Arduino : 6 Steps - Instructables

The library makes connecting the DS1302 to your Arduino straightforward, as it uses simple digital pins and is not reliant on more complex communication protocols like I2C.

If you are using the standard Virtuabotix DS1302 module, it typically requires a 3-wire interface (I2C is not used for the DS1302; it uses a serial protocol). // Set time: (second, minute, hour, dayOfWeek, date,

: Obtain the library as a ZIP file from the ArduinoRTClibrary GitHub.

You can choose any digital pins you like, but pins 6, 7, and 8 are a common convention used in many tutorials, including the one from Virtuabotix itself. Once the module is wired, you can proceed to the software setup.

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice