Virtuabotixrtc.h Arduino Library Info

| Problem | Likely Cause | Solution | |---------|--------------|----------| | Time resets when powering off | No backup battery | Install a CR2032 coin cell in the RTC module | | Wrong time after re-upload | Setting time every boot | Comment out setDS1302Time after first use | | Weird characters on Serial | Baud rate mismatch | Ensure Serial.begin(9600) matches monitor | | Library compile error | Wrong pin order | Check VirtuabotixRTC myRTC(clk, dat, rst) | VirtuabotixRTC vs. RTClib | Feature | VirtuabotixRTC (DS1302) | RTClib (DS1307/DS3231) | |---------|-------------------------|-------------------------| | Interface | 3-wire (any pins) | I2C (A4/A5 on Uno) | | Accuracy | ±2 minutes/month | DS3231: ±2 minutes/year | | Battery life | ~5 years | ~10 years | | Ease of use | Very simple | Simple, more features |

void loop() // Nothing here – this is a one‑time setup

// Print the date Serial.print("Date: "); Serial.print(myRTC.dayofmonth); Serial.print("/"); Serial.print(myRTC.month); Serial.print("/20"); Serial.print(myRTC.year); virtuabotixrtc.h arduino library

Serial.println("Time set on RTC.");

void setup() Serial.begin(9600);

// Print the time Serial.print(" – Time: "); Serial.print(myRTC.hours); Serial.print(":"); Serial.print(myRTC.minutes); Serial.print(":"); Serial.println(myRTC.seconds);

void setup() pinMode(ledPin, OUTPUT); Serial.begin(9600); | Problem | Likely Cause | Solution |

void setup() Serial.begin(9600);

delay(1000); // Update every second

Наверх