🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    RTC acting weird

    Core 2
    4
    9
    11.1k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      tom8787
      last edited by

      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 ...

      1 Reply Last reply Reply Quote 0
      • T
        tom8787
        last edited by

        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?

        1 Reply Last reply Reply Quote 0
        • felmueF
          felmue
          last edited by felmue

          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

          GPIO translation table M5Stack / M5Core2
          Information about various M5Stack products.
          Code examples

          T 1 Reply Last reply Reply Quote 0
          • T
            tom8787 @felmue
            last edited by

            @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.

            1 Reply Last reply Reply Quote 0
            • T
              tom8787
              last edited by

              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 ...

              1 Reply Last reply Reply Quote 0
              • Y
                yusukef3a
                last edited by

                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")

                1 Reply Last reply Reply Quote 1
                • felmueF
                  felmue
                  last edited by

                  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

                  GPIO translation table M5Stack / M5Core2
                  Information about various M5Stack products.
                  Code examples

                  1 Reply Last reply Reply Quote 0
                  • m5stackM
                    m5stack
                    last edited by

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

                    https://github.com/m5stack/M5Core2

                    1 Reply Last reply Reply Quote 0
                    • felmueF
                      felmue
                      last edited by

                      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

                      GPIO translation table M5Stack / M5Core2
                      Information about various M5Stack products.
                      Code examples

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post