OK, sorry I'm using RTClib library. Iv looked in the .h and found:
/** DS3231 Alarm modes for alarm 1 */
enum Ds3231Alarm1Mode {
DS3231_A1_PerSecond = 0x0F, /**< Alarm once per second */
DS3231_A1_Second = 0x0E, /**< Alarm when seconds match */
DS3231_A1_Minute = 0x0C, /**< Alarm when minutes and seconds match */
DS3231_A1_Hour = 0x08, /**< Alarm when hours, minutes
and seconds match */
DS3231_A1_Date = 0x00, /**< Alarm when date (day of month), hours,
minutes and seconds match */
DS3231_A1_Day = 0x10 /**< Alarm when day (day of week), hours,
minutes and seconds match */
Iv tried different numbers for day of the week with no luck. The adafruit RTClib library uses 0 - 6 As when I print out now.dayOfTheWeek() it prints 6 for Saturday.
I looked at the library sources. It maps the library's 0-6 = Sunday-Saturday by moving 0 to 7 so the chip's 1-7 is Monday-Sunday. It looks like it never uses a DoW read from the chip but sets the DoW based on the date. As long as the chip date/time was last set by this library, the alarm should be working.
Is it possible that the date/time was last set by some other library that uses a different mapping of DoW?
Try the example sketch "DS3231_alarm" to make sure the alarm is working. This sets the alarm to 10 seconds in the future.
If it works with the alarm mode is set to DS3231_A1_Second , try the other alarm mode options:
DS3231_A1_Minute
DS3231_A1_Hour
DS3231_A1_Date
DS3231_A1_Day
Each one of those should work because, after 10 seconds, the entire date/time will match the alarm date/time.
I see the problem: rtc.setAlarm1(DateTime(6, 10, 0, 0), DS3231_A1_Day);
This matches the DateTime constructor: DateTime(year, month, day, hour = 0, min = 0, sec = 0);
In other words: 10/0/2006 00:00:00
(Any guess what day of the week that was?)
That is probably NOT going to be a Saturday and it certainly won't be 10:00:00.
I think this might work: rtc.setAlarm1(DateTime(TimeSpan(6+1, 10, 0, 0).totalseconds()), DS3231_A1_Day);
TimeSpan is an offset in seconds. When used as a DateTime it is shifted to Saturday, January 1st, 2000. Unfortunately, that makes DoW 0-6 Saturday-Friday instead of Sunday-Saturday. I think you have to add 1 to get 0-6 to be Sunday-Saturday. TimeSpan(6+1, 10, 0, 0) -> "Saturday, January 8th, 2000 at 10:00:00"
The alarm triggers when the current time matches the settings in the alarm registers. If you have an alarm time that will never be matched by an actual time, then you'll just never get an alarm. I don't think there's any error checking.