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

    RTC example for the M5Stack

    Micropython
    5
    10
    20.3k
    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.
    • W
      Wolli01
      last edited by

      Does anyone have a running RTC example for the M5Stack what about UiFlow?
      This is mine what I use on my Wipy but don't want to run on the M5Stack.

                  #rtc.ntp_sync("de.pool.ntp.org", update_period=3600) # Datum und Uhrzeit holen
                  rtc.ntp_sync("de.pool.ntp.org")
                  while not rtc.synced():
                      machine.idle() # save power while waiting
      
      
                  utime.timezone(TimeDiff)
                  time1 = utime.localtime() # Übergabe Datum und Uhrzeit in die Variable time1
      
                  #time1 = rtc.now() # Übergabe Datum und Uhrzeit in die Variable time1
                  startzeit = time.time()
      
                  LogDateTime = "{}.{:}.{:};{:0>2d}:{:0>2d}:{:0>2d}".format(time1[2], time1[1], time1[0], time1[3], time1[4], time1[5])
                  LogDate = "{}.{:}.{:}".format(time1[2], time1[1], time1[0])
                  LogTime = "{:0>2d}:{:0>2d}:{:0>2d}".format(time1[3], time1[4], time1[5])
                  break
      
      1 Reply Last reply Reply Quote 0
      • lukasmaximusL
        lukasmaximus
        last edited by

        Hi @Wolli01 Only M5StickC has built in RTC. M5Stack only supports NTP, but RTC requires an external module

        E R 3 Replies Last reply Reply Quote 0
        • W
          Wolli01
          last edited by

          And how can I use NTP in MicroPython to get the time?

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

            I have the same issue. Trying to work with a DS3231 RTC module but it seems to interfere on I2C level with M5. Any solution found ? KInd Regards, Tony

            1 Reply Last reply Reply Quote 0
            • lukasmaximusL
              lukasmaximus
              last edited by

              Hi I was just able to use the ds1307 rtc module with M5stack core in arduino, by using adafruits RTClib library https://github.com/adafruit/RTClib/

              1 Reply Last reply Reply Quote 0
              • lukasmaximusL
                lukasmaximus
                last edited by

                if you are using micropython and have a ds1307 you can use the excellent library created by mcauser https://github.com/mcauser/micropython-tinyrtc-i2c

                1 Reply Last reply Reply Quote 0
                • E
                  Efried @lukasmaximus
                  last edited by

                  @lukasmaximus Could you please help solving the problem by giving a micropython example , I need to sync time via ntp because after booting it is zero.

                  many thanks

                  1 Reply Last reply Reply Quote 0
                  • R
                    rupin.chheda @lukasmaximus
                    last edited by

                    @lukasmaximus Why cant we sync the RTC with Network time?

                    1 Reply Last reply Reply Quote 0
                    • lukasmaximusL
                      lukasmaximus
                      last edited by

                      I created a guide on hackster.io using micropython check it out here https://www.hackster.io/lukasmaximus89/rtc-modules-with-m5stack-46636b you should be able to sync it with ntp by using the datetime function of ds1307 and ntp with settime() this forum post explains it https://forum.micropython.org/viewtopic.php?t=2440

                      1 Reply Last reply Reply Quote 0
                      • E
                        Efried @lukasmaximus
                        last edited by

                        @lukasmaximus RTC functionality is weak, ntp_syc does not work. Any M5 example?
                        many thanks

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