Timeline for Arduino Time Library and RTC Libraries
Current License: CC BY-SA 4.0
13 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Nov 5, 2020 at 13:20 | comment | added | RickH | thanks for all of your help. I will post the final code as an answer for anyone else needing to learn this. | |
| Nov 5, 2020 at 13:11 | comment | added | Majenko |
That looks right, yes. Though you don't need the tmElements_t struct at all since all you're dealing with is simple numbers. tmElements_t is just a convenient way of bundling them all together if you want to pass it to another function. Just Serial.print(hour());
|
|
| Nov 5, 2020 at 13:04 | comment | added | RickH | Thanks that worked. Looking at my updated code, to make sure I am not deceiving myself, are the outputs of tm.Hour tm.Minute. tm.Second Time Library values which are updated from the RTC every 5 seconds ? And am I not creating an Object every loop? | |
| Nov 5, 2020 at 12:42 | comment | added | Majenko | Because you're constantly changing the sync provider and interval. You set those once and once only in setup, and never again. | |
| Nov 5, 2020 at 12:32 | comment | added | RickH | Why does output alternate values for tm.hour, etc? See bottom of updated question. thanks | |
| Nov 4, 2020 at 14:36 | comment | added | RickH | I updated my post with help provided. Almost have it understood. | |
| Nov 4, 2020 at 14:35 | review | Suggested edits | |||
| Nov 5, 2020 at 21:33 | |||||
| Nov 4, 2020 at 12:35 | comment | added | Majenko |
It's a little more complex than that. TimeLib uses millis() to keep track of the time. It regularly updates its internal idea of what the time is depending on setSyncInterval(). when you ask for hour(), if more time has passed since it last got the real time that you specified in setSyncInterval() it will go and get the time from the RTC. Otherwise it will just tell you what it thinks the time is according to its own internal calculations.
|
|
| Nov 4, 2020 at 12:33 | comment | added | RickH | "setSyncProvider() doesn't send anything to the RTC, it gets the time from the RTC on a regular basis and updates the TimeLib with the current time." Yes, so If hour() is the time from the TimeLib Library then setSyncProvider() makes hour() equal to RTC hour? | |
| Nov 4, 2020 at 12:25 | comment | added | RickH | @Edgar Bonet - Using interrupt pin looks very nice and clean. If Pin 2 is used on Arduino for the interrupt, which pin does Pin 2 connect to on the RTC? I assume it is in addition to the SCL and SDA pins (?). | |
| Nov 4, 2020 at 12:24 | comment | added | Majenko |
now is the time from the RTC at the moment you assign the now object. .hour() is just the hour contained inside that object. hour() is the time from the TimeLib library, yes. setSyncProvider() doesn't send anything to the RTC, it gets the time from the RTC on a regular basis and updates the TimeLib with the current time.
|
|
| Nov 4, 2020 at 12:19 | comment | added | RickH | -I have read much about these libraries and still confused. Thanks for your help. Couple follow ups: 1. Does function now.hour() get time from RTC? 2. Does hour() get time from Time Library? 3. Does setSyncProvider() set hour() to the RTC ? | |
| Nov 3, 2020 at 16:20 | history | answered | Majenko | CC BY-SA 4.0 |