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

    M5Stamp PLC Controller with M5StampS3 cannot write and read current Date and Time

    Scheduled Pinned Locked Moved PRODUCTS
    5 Posts 3 Posters 1.5k Views
    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.
    • M Offline
      MCU1536
      last edited by

      Hi,

      When M5Stamp PLC Controller with M5StampS3 got the power supply.
      It can write and read the current Date and Time.
      But after I turned of the power supply for 1 day.

      The PLC shown "Sunday, 0 Jan 2090 33:20:39"
      It is not the current Date and Time.

      Could you recommend me to solve this?

      Thank you

      1 Reply Last reply Reply Quote 0
      • robskiR Offline
        robski
        last edited by

        This post is deleted!
        felmueF 1 Reply Last reply Reply Quote 0
        • felmueF Offline
          felmue @robski
          last edited by

          Hello @MCU1536

          assuming you are using Arduino and the M5StamPLC library then it is clear as to why the date and time are not retained. There is no code in the M5StamPLC library to enable charging the RTC backup battery.

          I created a PR which enables RTC backup battery charging.

          Thanks
          Felix

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

          M 1 Reply Last reply Reply Quote 0
          • M Offline
            MCU1536 @felmue
            last edited by

            Hello felmue,

            After downloaded it and unzipped.
            I copied 3 files as below and then replace them.

            1. M5StamPLC.cpp at C:\Users\xxx\Documents\Arduino\libraries\M5StamPLC\src
            2. rx8130.cpp at C:\Users\xxx\Documents\Arduino\libraries\M5StamPLC\src\utils\rx8130
            3. rx8130.h at C:\Users\xxx\Documents\Arduino\libraries\M5StamPLC\src\utils\rx8130

            It works well.
            Thank you very much for your help.

            M 1 Reply Last reply Reply Quote 0
            • M Offline
              MCU1536 @MCU1536
              last edited by

              Hello felmue,

              When PLC was disconnected the power supply.
              time.tm_wday cannot remember. Other are correct.

              But PLC got the power supply.
              It worked normally as below code.


              char Text[100];
              static struct tm time;
              char DayOfWeek[7][10] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
              char MonthOfYear[12][4] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};

              sprintf(Text, "%s, %d %s %d %02d:%02d:%02d",
              DayOfWeek[time.tm_wday],
              time.tm_mday,
              MonthOfYear[time.tm_mon],
              time.tm_year + 1902,
              time.tm_hour,
              time.tm_min,
              time.tm_sec);

              Serial.print(Text);


              Result

              Wednesday, 19 Nov 2025 16:38:35

              Thank you

              1 Reply Last reply Reply Quote 0

              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

              With your input, this post could be even better 💗

              Register Login
              • First post
                Last post