resetting RTC on Data logger shield
Moderators: adafruit_support_bill, adafruit

resetting RTC on Data logger shield

by delerious on Tue Dec 25, 2012 12:45 pm

Is there any way to reset the RTC time (unplug, pull battery, re-insert)? I'm off by about 2 days or so. 2012/12/23 20:20:51 on 2012/12/25 11:44 - updating every 3 seconds.

Thanks
delerious
 
Posts: 12
Joined: Thu Nov 22, 2012 5:09 pm

Re: resetting RTC on Data logger shield

by pgrunwald on Tue Dec 25, 2012 1:56 pm

See the DS1307 program in the RTCLib examples.

Code: Select all | TOGGLE FULL SIZE
    // following line sets the RTC to the date & time this sketch was compiled
    RTC.adjust(DateTime(__DATE__, __TIME__));

pgrunwald
 
Posts: 33
Joined: Tue Jul 14, 2009 10:32 pm

Re: resetting RTC on Data logger shield

by delerious on Tue Dec 25, 2012 7:02 pm

That's what I'm using, but it doesn't seem to make a difference.
delerious
 
Posts: 12
Joined: Thu Nov 22, 2012 5:09 pm

Re: resetting RTC on Data logger shield

by Lucutis on Mon Dec 31, 2012 2:42 am

I have experienced the very same problem. I reset the RTC with the compile time and then re-comment that code line back out. But my RTC drifts by about an hour a day. At least you know you're not alone.
Lucutis
 
Posts: 1
Joined: Tue Jul 03, 2012 11:59 pm

Re: resetting RTC on Data logger shield

by adafruit_support_bill on Mon Dec 31, 2012 8:10 am

If you are using the conditional reset code from the library example, you can pull the battery for a few minutes to stop the clock.

The DS1307 is not temperature compensated and can drift considerably. For better accuracy, there is the Chronodot. https://www.adafruit.com/products/255
User avatar
adafruit_support_bill
 
Posts: 31071
Joined: Sat Feb 07, 2009 10:11 am

Re: resetting RTC on Data logger shield

by poledust on Thu Jan 03, 2013 8:33 pm

I am having a problem with this very RTC it does seem to keep the time ok but when it gets to the end of the hour it counts higher then 60 it does weird stuff I just pulled the battery then reloaded the code just waiting to see if the problem goes away. The one question that I have is how do I change the time to 12hr instead of 24hr I would also like to see am and pm any help I would appreciate thanks!
poledust
 
Posts: 26
Joined: Thu Jan 03, 2013 8:25 pm

Re: resetting RTC on Data logger shield

by adafruit_support_bill on Thu Jan 03, 2013 8:59 pm

The RTC Lib does not have support for 12-hour AM/PM mode. But it is not difficult to test for hour > 12 and handle it in your code.
User avatar
adafruit_support_bill
 
Posts: 31071
Joined: Sat Feb 07, 2009 10:11 am

Re: resetting RTC on Data logger shield

by poledust on Thu Jan 03, 2013 9:12 pm

why when the chip is capable of 12hr. are you saying your lib or you saying any lib.
poledust
 
Posts: 26
Joined: Thu Jan 03, 2013 8:25 pm

Re: resetting RTC on Data logger shield

by poledust on Thu Jan 03, 2013 9:27 pm

So I reset the rtc and now it started to add minutes to the time it is now 4 minutes ahead of my computer. I only wish you guys would have added this info about it not being able to do 12hr time or am/pm to your product info page I would have just bought the next model up if that were the case it seems that other people may be having the same problem and more but the response that I have read from you guys is that, Hey this product is not very accurate but if you would like to buy one that is, then you should purchase our more expensive model. well how do I know that when I get that one that I wont be on here asking for support and then the response is hey that it is not quiet that accurate but you can just purchase our mega model I just feel that I may have been misled!
poledust
 
Posts: 26
Joined: Thu Jan 03, 2013 8:25 pm

Re: resetting RTC on Data logger shield

by adafruit_support_bill on Thu Jan 03, 2013 9:45 pm

There are several variations on RTCLib for the Arduino. None that I know of support the 12-hour mode of the 1307.

The limitations of the DS1307 are clearly stated in the product description: http://adafruit.com/products/264
The DS1307 is simple and inexpensive but not a high precision device. It may lose or gain up to 2 seconds a day. For a high-precision, temperature compensated alternative, please check out the ChronoDot.


If yours is drifting at the rate you report, there is clearly something wrong with it. Please contact support@adafruit.com with a link to this thread for a replacement.
User avatar
adafruit_support_bill
 
Posts: 31071
Joined: Sat Feb 07, 2009 10:11 am

Re: resetting RTC on Data logger shield

by poledust on Thu Jan 03, 2013 11:09 pm

So I pulled the battery for about five minutes ran the code again the time is now reading the same time as my computer that it was loaded from I let it run for about a half hour then I unplugged the power with the battery still in waited two minutes then plugged the power back in it is now holding the time when the power is removed so it looks like it is working properly I will keep an eye out for any weird stuff if I see anything then I will contact support about a return. I do disagree with you about the product page "....." as I have seen on other post to the forum that other people have the same question about 12hr time! not saying you guys have to post that info but I would not have purchased this particular product. I would have gone with the ChronoDot in the first place! The problem is not the second or two a month it is the fact that it does not keep 12hr time in the lib, I dont know if you guys or some one else wrote the lib but you guys do know that the lib doesn't allow this chip to use the 12hr and you have already been asked the question from other users I think it just would be nice to have known that before I purchased it and waited ten days now I will have to wait another ten days to get the one I would like to have had in the first place. don't get me wrong I'm just trying to point out that it would have been helpful information! So my question is do you know of code to get the 12hr I am new to this stuff, and it would greatly help me be able to get a starter or even a hole working code and if it has the am/pm then that would be even better!
I do thank you for your help!

The limitations of the DS1307 are "clearly stated in the product description" : http://adafruit.com/products/264
The DS1307 is simple and inexpensive but not a high precision device. It may lose or gain up to 2 seconds a day. For a high-precision, temperature compensated alternative, please check out the ChronoDot.


If yours is drifting at the rate you report, there is clearly something wrong with it. Please contact support@adafruit.com with a link to this thread for a replacement.[/quote]
poledust
 
Posts: 26
Joined: Thu Jan 03, 2013 8:25 pm

Re: resetting RTC on Data logger shield

by poledust on Thu Jan 03, 2013 11:38 pm

photo.JPG
well I think something might be wrong with it! as you can see it shows that it is 20:99 but it will show that then show the right time after the minute is up once it move to the next hour!! any advice!
photo.JPG (134.33 KiB) Viewed 1181 times
poledust
 
Posts: 26
Joined: Thu Jan 03, 2013 8:25 pm

Re: resetting RTC on Data logger shield

by poledust on Thu Jan 03, 2013 11:44 pm

poledust wrote:
photo.JPG

Sorry the time was a little off cause I was transferring it to my computer but the time was 8:00 /20:00 but it showed 20:99 then when the minute was over it went to 20:01
poledust
 
Posts: 26
Joined: Thu Jan 03, 2013 8:25 pm

Re: resetting RTC on Data logger shield

by adafruit_support_bill on Fri Jan 04, 2013 6:49 am

I would have gone with the ChronoDot in the first place! The problem is not the second or two a month it is the fact that it does not keep 12hr time in the lib,

The ChronoDot uses the same library as the DS-1307. It just has more accurate time regulation. I will see about adding a note to the product description regarding the 12-hour mode limitation.

the time was 8:00 /20:00 but it showed 20:99 then when the minute was over it went to 20:01

Can you post the code you are using?

So my question is do you know of code to get the 12hr

I don't have any code handy that you could just drop-in, but the basic logic is:

Code: Select all | TOGGLE FULL SIZE
if (hour >= 12)
{
    PM = true;
}
if (hour > 12) // afternoon hours
{
    displayHour = hour - 12;
}
if (hour == 0)  // special case for midnight
{
    displayHour = 12;
}
User avatar
adafruit_support_bill
 
Posts: 31071
Joined: Sat Feb 07, 2009 10:11 am

Re: resetting RTC on Data logger shield

by poledust on Sat Jan 05, 2013 6:21 pm

ok I found that same code and tried it it seems to work well but my rtc is not working correctly I watched it closer and found exactly what it was doing..
when the time rolls over from one hour to the next say 12:59 to 1:00 the time will change to 1:09 (the time is correct all the time accept during this period ) what happens next is every minute that passes it counts by ten then some where in that time it just changes at random amounts once the time reaches say 1:10 then the hour and minutes work correctly keeping the right time but the second climb at random amout like starting at say 1:10:09 second instead of 1:10:01 and the numerals will go up to 99 (1:99:99 then 1:10:99 then 1:11:random for 09 to 99 always climbing up never down) the seconds will do this during the hour but the hour and minutes seem to be keeping up!




Code: Select all | TOGGLE FULL SIZE
// Date and time functions using a DS1307 RTC connected via I2C and Wire lib

#include <Wire.h>
#include "RTClib.h"
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

RTC_DS1307 RTC;

void setup () {
    Serial.begin(57600);
    Wire.begin();
   
    lcd.begin(20, 4);
    RTC.begin();
   
  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__));
  }
 
 
   lcd.setCursor(0,0);
   lcd.print("Starting up");
   lcd.setCursor(0,1);
   lcd.print("*** WELCOME! ***");
   lcd.setCursor(0,3);
   lcd.print("Initializing");
     delay(4000);
   lcd.clear();
     
 
 
}

void loop () {
    DateTime now = RTC.now();
   
        lcd.setCursor(0,0);
lcd.print(now.year(), DEC);
        lcd.setCursor(4,0);
    lcd.print("/");
        lcd.setCursor(5,0);
    lcd.print(now.month(), DEC);
        lcd.setCursor(6,0);
    lcd.print("/");
        lcd.setCursor(7,0);
    lcd.print(now.day(), DEC);
       
        lcd.setCursor(12,0);
    lcd.print(now.hour(), DEC);
        lcd.setCursor(14,0);
    lcd.print(":");
        lcd.setCursor(15,0);
    lcd.print(now.minute(), DEC);
        lcd.setCursor(17,0);
    lcd.print(":");
        lcd.setCursor(18,0);
    lcd.print(now.second(), DEC);
       
   
   

    delay(1);
}
poledust
 
Posts: 26
Joined: Thu Jan 03, 2013 8:25 pm