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

For RTC breakouts, etc., use the Other Products from Adafruit forum

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
fredpet
 
Posts: 22
Joined: Wed Feb 13, 2019 6:30 pm

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

Post by fredpet »

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.

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

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

Post by adafruit_support_bill »

There is this section of code in the example sketch:

Code: Select all

  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.)

User avatar
fredpet
 
Posts: 22
Joined: Wed Feb 13, 2019 6:30 pm

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

Post by fredpet »

thanks a lot for your fast answer!
fred

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

Return to “Clock Kits (discontinued)”