0

real time clock ds3231 - where from does it get the time?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

real time clock ds3231 - where from does it get the time?

by fredpet on Mon May 13, 2019 5:32 am

hi folks,
I'm using the real time clock ds3231 (https://learn.adafruit.com/ds3231-preci ... eatherwing).
In combination with a featherFONA I loaded the test sketch and the clock works very fine from the first moment on.

Now my question - just for understanding the context:
Where from does the clock get the actual time?
I havent found any documentation about this...

Many thanks in advance
fred

P.S.: The link 'Maxim product page for the DS3231' in the download section of the above mentioned link seems to be broken.

fredpet
 
Posts: 12
Joined: Wed Feb 13, 2019 6:30 pm

Re: real time clock ds3231 - where from does it get the time

by adafruit_support_bill on Mon May 13, 2019 6:00 am

There is this section of code in the example sketch:
Code: Select all | TOGGLE FULL SIZE
  if (rtc.lostPower()) {
    Serial.println("RTC lost power, lets set the time!");
    // following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
  }


When you compile that code to upload to the Feather, the compiler will replace the "__DATE__" and "__TIME__" symbols with the current date and the current time. So the first time you run the code, it will initialize the RTC with the current date and time. (actually the data and time when it was compiled, so you will be a few seconds behind since it takes a little while to upload the code.)

adafruit_support_bill
 
Posts: 72788
Joined: Sat Feb 07, 2009 10:11 am

Re: real time clock ds3231 - where from does it get the time

by fredpet on Mon May 13, 2019 6:26 am

thanks a lot for your fast answer!
fred

fredpet
 
Posts: 12
Joined: Wed Feb 13, 2019 6:30 pm

Please be positive and constructive with your questions and comments.