DS3231 on M5Stack - Need your Help

  • HI everyone,

    I am currently trying to use a DS3231 external RTC on my M5Stack core grey.

    I have tried many different libraries but problem remains the same :

    • I know the RTC is seen. I have run I2C scan and my DS3231 RTC has the 0x57 address.
    • I am able to set the current time into the RTC.
    • I am able to read the RTC. But the info displayed on the Lcd is not correct or maybe the reading is wrong. The seconds displayed are chaotic and the minutes go down when the seconds reach 60...

    For example :

    alt text

    Here, for this exemple, I am using the RTCLib library from Adafruit.

    Here is my code :

    #include "RTClib.h"
    #include <M5Stack.h>
    #include <Wire.h>

    RTC_DS3231 rtc;

    char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

    void setup () {


    if (! rtc.begin()) {

    M5.Lcd.println("Couldn't find RTC");


    //Adjust the time to the current one
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));


    void loop () {

    //Getting the time
    DateTime now = rtc.now();
    //Printing it on M5 Lcd
    M5.Lcd.print(now.year(), DEC);
    M5.Lcd.print(now.month(), DEC);
    M5.Lcd.print(now.day(), DEC);
    M5.Lcd.print(" (");
    M5.Lcd.print(") ");
    M5.Lcd.print(now.hour(), DEC);
    M5.Lcd.print(now.minute(), DEC);
    M5.Lcd.print(now.second(), DEC);


    My question are :

    • what is wrong with my code ?
    • while scanning for I2C adress, I can find 4 different adresses. I know RTC is 0x57 because when disconnecting the DS21 this one disapear frome the scan. But is it possible tha the other devices scanned interfere with my RTC ?
    • should I specify which adress of the I2C to read ? something like Wire.requestFrom(0x57, ...) ?

    Thank you for your help, I am stuck here for 2 days...!

    Best wishes to everybody for the new year.


  • Hello @morguane

    I2C address 0x57 is for the EEPROM IC on your board, the DS3231 uses 0x68. Unfortunately 0x68 already is used internally by MPU6886 of the M5Stack Gray.

    You'll need to setup a second I2C bus (using different GPIOs) or get a different RTC IC with a different I2C address not already used internally.

    Good luck!