Serial.print("Logged: "); Serial.println(temperatureC);
void loop() // This is the most important line. It reads the RTC's current time // into the library's variables. myRTC.updateTime();
When you first get an RTC module, it has random garbage data. You must set the current time. The key concept is that you set the time , upload the sketch, and then comment out the set functions in subsequent uploads. virtuabotixrtc.h arduino library
void loop() // Your main code here
#include <virtuabotixRTC.h>
#include <Wire.h> #include <VirtuabotixRTC.h>
For most logging applications (1 read per second), this is negligible. However, if you attempt to read the RTC inside a tight loop with millisecond delays, you may experience bus contention or timing jitter. Serial
// Uncomment to set time (year offset: 25 = 2025) // myRTC.setDS1302Time(0, 49, 14, 4, 21, 4, 25);
that defines which Arduino pins are used for the CLK, DAT, and RST connections. setDS1302Time(sec, min, hr, dayW, dayM, mon, yr) You must set the current time