M5Stack D3231 uRTC module

  • Hi,
    I would like to inform that I just published a small repo on Github, title: M5Stack_DS3231_uRTC. It is a module for use in MicroPython. It uses a modified version of Adafruit-uRTC library (which Adafruit marked 'Deprecated'). Beside various modifications in the file urtc.py, like the use of dictionaries, I added several functions as: weekday(), isLeapYear(), daysInMonth(), yearday() and cur_month(). The module provides the use of an external DS3231 RTC device with a M5Stack Core1 (BASIC) as host, connected via I2C.
    See: M5Stack_DS3231_uRTC,
    The main.py file is a combination of some tests: a) getting /setting date and time from the external RTC; b) read and display images from flash and from SD-Card; c) use of an MYVARS class to save variables and use them globally. The module is tested on a Core1 (BASIC).

  • Troubleshooting

    The past week I am trying 2 different external DS3231 devices on a m5stack FIRE. I have a GROVE Hub (with 3 I2C connectors) connected to the Port A of the Fire. The DS3231 I connected to the I2C Hub. I connected a MiniWare LA104 analyzer to a 2nd port otf the I2C Hub. a M5 RGB LED I connected to Port B of the Fire. The main script I programmed to let the middle RGB LED blink at the moment the script calls rtc.datetime(). Everything works except the readings from the DS3231 clock register (Addresses 0x0 - 0x6) remain mostly static. I don't see the seconds increase. I see the minutes increase but after 3 increases jump back to zero, e.g.: time is 18:40:00 After a minute the time shows 128:41:00, then 18:42:00 and then back to 18:40. This while at that moment the script runs inside a loop. So, the initial setting of the datetime registers only occur at the startup moment.

    I created a link to a Dropbox folder with the script main.py, the rtc classes in urtc.py and other files used during a run. Also a subfolder with various images that will give some impressions about the setup and signals visualized.
    Link: RTC_folder_in_Dropbox

    Why are the datetime rtc registers not updating?

    I modified the urtc.py file. Added various functions. Also added some try...except... blocks to prevent crashes in case functions receive a NoneType value or in case an I2C bus error occurs (this happened once in a while since I have the I2C analyzer connected to the bus. Mayby the handling of the analyzer did cause some noises on on or more lines.

  • I have some experience with programming RTC modules but this problem I am not (yet) able to solve.

    Is there anyone who read my post above and has looked into the code to see if he/she can give me a hint
    to solve this problem of RTC not updating ?

    See my tweet in May 2021:

    tweet in may 2021.


    At startup :
    if flag 'power_lost' is True:
    the external DS3231 is set with pre-determined datetime (adjust by hand)
    next the built-in RTC is started with the datetime from the DS3231

    if the flag 'power_lost is False:
    the built-in RTC is started with the datetime from the DS3231

    During the main loop displaying the datetime from the built-in RTC.

    I put a short video in the images folder inside the dropbox folder (see the link in my post above).