Use VirtuabotixRTC for 90% of hobbyist projects. Switch to RTClib only if you need alarms, temperature sensing, or powermanagement features.
The DS1302 module has 5 pins. Use the following typical connection for an Arduino Uno: DS1302 Pin Arduino Pin (Example) Description Power supply GND CLK / SCLK Serial Clock DAT / I/O Bidirectional Data RST / CE Reset / Chip Enable 3. Basic Code Guide
| Problem | Likely Cause | Solution | |---------|--------------|----------| | Reads 85:85:85 | RTC not initialized or first boot | Run the set-time sketch once. | | Time resets on power loss | Backup battery dead | Replace CR2032 battery on module. | | No Serial output | Wrong baud rate | Ensure Serial.begin(9600) matches monitor. | | Compilation errors | Wrong library installed | Remove other DS1302 libraries (e.g., DS1302RTC). | | Garbage values | Floating pins | Add 10k pull-up resistors on CLK/DAT/RST or use shorter wires. |
It focuses on the most commonly requested functions, keeping your code clean and efficient. Getting Started: Wiring and Code The DS1302 typically uses five pins: (Data), and
Because this library is often not in the standard Arduino Library Manager, you typically need to install it manually: