While the Virtuabotix library is excellent for beginners using the DS1302, many advanced users eventually migrate to the Adafruit RTClib.
Sets the time on the DS1302 chip.
Note: dayofweek (1=Sunday, 7=Saturday) is usually ignored by the DS1302 but required for compatibility.
Returns a formatted string: HH:MM:SS.
For the DS3231, the library exposes alarm functions that many other libraries bury:
myRTC.setAlarm1(0, 30, 16, 5, 0); // Alarm at 16:30:00 on day 5
myRTC.turnOnAlarmInterrupt();
You can then read the alarm flag with myRTC.checkIfAlarm1() and clear it. This is critical for low-power projects that wake the Arduino only when needed. virtuabotixrtch arduino library
| Library | RTC Chip | Advantages | |---------|----------|------------| | RTClib (Adafruit) | DS1307, DS3231, PCF8523 | Actively maintained, alarms, temperature | | DS1302 (by Matthias Hertel) | DS1302 | More robust, works on ESP32 | | RtcDS1302 (by Makuna) | DS1302 | Efficient, supports all MCUs, burst mode | | TinyRTC | DS1307 | For older TinyRTC modules |
The DS1302 is a trickle-charge real-time clock manufactured by Dallas Semiconductor (now Maxim Integrated). Key features: While the Virtuabotix library is excellent for beginners
When it comes to Arduino projects, one of the most common hurdles is dealing with time. The built-in millis() and delay() functions are great for short intervals, but what happens when you need to know the actual date and time? What if you need to turn a relay on at 7:00 PM, or log temperature data with a precise timestamp?
That’s where Real Time Clocks (RTCs) come in, and specifically, where the Virtuabotix RTC library shines. Sets the time on the DS1302 chip
In this post, we’ll explore why this library is a solid choice for DS1302-based RTC modules and how to get it up and running in your next project.