rtclib 3231-trinket pro

I have trouble setting Day of the week. I am able to set time using the following:

rtc.adjust(DateTime(2017, 7, 16, 6, 21, 0));

How is the day of the week set?


Which RTC library are you using? Can you post your code? HowToPostCode

rtclib 3231-trinket pro
How is the day of the week set?

With rtclib.h the day of the week is not set in or read from the ds3231 chip memory. It is a calculated value (0==Sunday and 6 == Saturday) based on the number of days since 01/01/2001.

Look at the rtclib library example program for the ds3231. It shows how to get the value with

char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
DateTime now = rtc.now();

There is a storage register(0x03) within the ds3231 chip which holds and increments a value from 0-7 at midnight, but it is not used by rtclib.h.

Why do you feel the need to set the day of the week?