Real time Clock - RTClib question

Hi,

I'm using the RTClib with a DS3231 on a Arduino Nano. Is there a way to just update the time (hour, min, sec) on the RTC without having to as well update everything else such as the year, month, day ?

It appears the only way to set the RTC time is with this command -
rtc.adjust(DateTime(year, month, day, hour, min, sec));

I'm building a retro style flip clock. Thanks in advance :slightly_smiling_face:

Hi
Before updating, read the values of Day Month and years, save in variables and when updating the RTC use these variables.

Good point. Thanks!

you can read that in a DateTime and just build a new DateTime

DateTime now = rtc.now();
rtc.adjust(DateTime(now.year(), now.month(), now.day(), 12, 0, 0)); // set only the time at 12 noon 

I didn't know that, that'll work perfectly for what I was after. Thank you!

The date and time registers can be written/accessed individually in the DS3231

Thank you! I'll have a go at figuring out how to do that

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.