Fix: Virtuabotixrtch Arduino Library
To use the library, you must first create an object. The constructor takes two arguments: the SDA pin and the SCL pin. For standard boards, we use A4 and A5 even though they are analog pins (they double as digital I2C).
Use VirtuabotixRTC for 90% of hobbyist projects. Switch to RTClib only if you need alarms, temperature sensing, or powermanagement features.
If your module has separate DS and SCLK pins (common on old DS1302 modules), do not use VirtuabotixRTC. That library is for I2C modules only (DS1307/3231). For DS1302, you need the DS1302 library. virtuabotixrtch arduino library
Your RTC module’s battery is not connected, or the module does not have a battery holder. Fix: Most cheap modules have a diode that prevents charging. Ensure a 3V coin cell is installed.
void setup() Serial.begin(9600);
The library is a classic tool used in the Arduino community to interface with Real-Time Clock (RTC) modules, most commonly the DS1302 chip . It allows makers to keep track of time—seconds, minutes, hours, days, and years—even when their Arduino is powered down, thanks to a small backup battery. The Clockmaker’s Ghost
// Use the device address the library expects (example: 0x68) and set starting pin if required VirtuabotixRTC myRTC(0x68); // constructor may vary by library version To use the library, you must first create an object
void setup() Serial.begin(9600); // Initialize serial communication
Custom format: "DD-MM-YY" , "MM/DD/YYYY" , etc. Use VirtuabotixRTC for 90% of hobbyist projects
Serial.print(myRTC.hours); Serial.print(":"); Serial.print(myRTC.minutes); Serial.print(":"); Serial.println(myRTC.seconds);
The library's simplicity makes it a favorite for a wide array of projects. Here are some common examples found in the community: