RTC acting weird



  • Hi all,

    There is something really weird with my RTC.
    I try to get the NTP time over WiFi, and then set the RTC with that time. Connecting the WiFi and getting the NTP time works flawless, the time shows correct, but then something goes wrong, and I can't figure out what. I tried it with the standard M5.Rtc structs, and now with the BM8563 library, but the result is the same: the time looks something like 13:00:00, and the hours (the 13 in this case) tick like seconds. The minutes and the seconds stay 00. The hours tick every second +1, sometimes until 19, sometimes until 35, ... and then restart from 00.

    This is my code:

    #include <I2C_BM8563.h>

    #include <M5Core2.h>
    #include <WiFi.h>
    #include <NTPClient.h>

    WiFiUDP ntpUDP;
    NTPClient timeClient(ntpUDP);

    #define BM8563_I2C_SDA 21
    #define BM8563_I2C_SCL 22

    I2C_BM8563 rtc(I2C_BM8563_DEFAULT_ADDRESS, Wire1);

    const char *ssid = "mySSID";
    const char *password = "myPassword";

    //RTC_TimeTypeDef RTCtime;

    int hour;
    int minute;
    int second;

    void setup() {
    M5.begin();
    Serial.begin(115200);

    WiFi.begin(ssid, password);
    Wire1.begin(BM8563_I2C_SDA, BM8563_I2C_SCL);
    rtc.begin();

    M5.Lcd.setTextSize(1);
    M5.Lcd.print("Connecting");

    while ( WiFi.status() != WL_CONNECTED ) {
    delay (500);
    M5.Lcd.print(".");
    }

    timeClient.begin();
    delay (1000);
    timeClient.update();

    hour = timeClient.getHours();
    minute = timeClient.getMinutes();
    second = timeClient.getSeconds();

    M5.Lcd.print("Got time ");
    M5.Lcd.print(hour);
    M5.Lcd.print(":");
    M5.Lcd.print(minute);
    M5.Lcd.print(":");
    M5.Lcd.println(second);

    I2C_BM8563_TimeTypeDef timeStruct;
    timeStruct.hours = hour;
    timeStruct.minutes = minute;
    timeStruct.seconds = second;
    rtc.setTime(&timeStruct);
    }

    void loop() {
    I2C_BM8563_TimeTypeDef timeStruct;

    M5.Lcd.setTextSize(2);
    M5.Lcd.setCursor(40,40);

    rtc.getTime(&timeStruct);

    M5.Lcd.printf("Time: %02d:%02d:%02d\n",timeStruct.hours, timeStruct.minutes, timeStruct.seconds);
    delay(1000);
    }

    Any help is greatly appreciated ...



  • UPDATE: there must be something wrong with my device, because even the rtc_wakeup example included in the M5Core examples gives me exactly the same. In the example, the time is set manually to 10:30:45, but immediately it shows on my device as 32:00:00 and the hours start counting as if they were seconds.

    Anyone else experienced this?



  • Hello @tom8787

    I am afraid you are correct and your device might be faulty.

    I can run your code from the first post just fine on my M5Core2. Also the rtc_wakeup example runs ok for me too.

    BTW: I had an RTC issue on one of my M5StickC Plus a while ago - maybe something similar is plaguing your device?

    Thanks
    Felix



  • @felmue said in RTC acting weird:

    RTC issue

    Hi Felix,

    Thanks a lot! I'll open up mine and see whether indeed there's something wrong with the soldering (or maybe just a flat battery).

    Kind regards,

    Tom.



  • Small update: I just used M5burner to reinstall the Factory Test, same result, so I'm getting in touch with the supplier, hopefully I can get a new one ...



  • Hi @tom8787
    I have same issue.
    I checked RTC IC (BM8563), it was mounted HYM8563S.
    i replaced BM8563 IT WORKED!!! (replace from M5StickC RTC ,its "BM8563")



  • Hello @yusukef3a

    that is interesting - thank you for sharing.

    I've just checked my M5Core2s and all three of them have a BM8563 mounted. I guess the HYM8563S in your M5Core2 is either faulty or it isn't fully compatible to begin with.

    @tom8787 - do you happen to have checked which brand is mounted in your M5Core2?

    Thanks
    Felix



  • Hi, we already update the lib to fix these issues. so please update your lib to the latest.

    https://github.com/m5stack/M5Core2



  • Hello @m5stack

    good to know. Thank you for fixing the issue and letting us know. I appreciate it.

    (I myself cannot test the fix though as I don't have any M5Stack devices with that specific RTC chip.)

    Thanks
    Felix