Datalogger RTC Problem

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
showup
 
Posts: 2
Joined: Sun Apr 08, 2012 12:09 pm

Datalogger RTC Problem

Post by showup »

I got me shield, assembled and it is up and running.
I used the code from "Light and Temperature logger walk through".
Spending hours i figured that the RTC is not updating time becaue for some reason the code is missing "RTC.adjust(DateTime(__DATE__, __TIME__));"

After correcting this, the time is updated.
However, i am still having trouble with RTC. For example, if the time when the code is uploaded to the card is say 10:30:10 each time when i try logging the time and date starts from 10:30:10. It means the clock is not running for some reason. Is that correct? Why is so? any advice is appreciated. Thank you.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Datalogger RTC Problem

Post by adafruit_support_bill »

That is because the RTC.adjust is always setting the time back to when the sketch was compiled. Once the clock is running, you don't need to adjust the time (except to correct for drift - or daylight savings time). The code to use is:

Code: Select all

  if (! RTC.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    RTC.adjust(DateTime(__DATE__, __TIME__));
  }

showup
 
Posts: 2
Joined: Sun Apr 08, 2012 12:09 pm

Re: Datalogger RTC Problem

Post by showup »

It is all working good now.
Thanks.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”