As specified in the ds3231 technical documentation, the day-of-week is in the buffer address 03h and the Rnage is 1-7.
The day-of-week register increments at midnight. Values that correspond to the day of week are user-defined but must be sequential (i.e., if 1 equals Sunday, then 2 equals Monday, and so on). Illogical time and date entries result in undefined operation.
Therefore I think the implementation in urtc.py (even for ds3231) is not correct as described in “Raspberry PI PICO/PICOW with MicroPython” 10.4. The program failed when the current_datetime.weekday value is incremented and reachs 7. The value is out of range of the days_of_week list.
I’m right or I have missed something.
Thanks a lot by advance.
Kr.
Hi.
I’m sorry. At the moment, I’m out of the office to test that.
If current_datetime.weekday returns 7, the days_of_week[] array will be out of range. So, you’ll need to subsctract one to the result of current_datetime.weekday result.
For example:
print('Day of the Week:', days_of_week[current_datetime.weekday-1])
Let me know if this fixes the issue.
Again, I don’t have a way to actually test this at the moment.
Regards,
Sara