Good afternoon, gentlemen! Tell me please, I am using the excellent RTClib library for my project.
I have little difficulties, for example, I want to store only the day of the week in the watch's memory (I don't want other data to change), how can I do this?
Construction rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0)); changes all data at once.
I need
You have already been answered in the national forum.
You can't change only part of the time.
First, read the current data from the clock, change what you need, fill it back.
DateTime old_time = rtc.now();
//change the day and month to 1st July, preserving the time of day and the year
DateTine new_time(old_time.year(),
7, // month = July
1, // day of month
old_time.hour(), old_time.minute() , old_time.second());
rtc.adjust(new_time);
an attempt to declare structure
DateTime dt = rtc.now();
outside the loop causes a panic and restart esp32
otherwise the subroutine void AfterN () does not know what "dt" is
what am I doing wrong?
If you have an ESP32 and WiFi access, why are you using an external RTC at all? ESP32 has built in RTC that can automatically sync to internet time servers using NTP.