Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Using RTC DS3231

    Scheduled Pinned Locked Moved LoPy
    4 Posts 4 Posters 360 Views 4 Watching
    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.
    • L Offline
      Lucas_Vieira
      last edited by

      Hi, guys. i need your help. i'm using a RTC DS3231 and i have this problem:
      teste_02.png

      I'm having this problem because of the least significant bit overflow?
      what kind of function could I apply to fix this problem?
      (00h address of seconds)

      teste_03.png

      I would like to ream from 0-59s in integer. Thank you for your supp!

      robert-hhR 1 Reply Last reply Reply Quote 0
      • E Offline
        Eric73
        last edited by

        So, your trouble is second RTC register is in BCD format.
        Something like this in line 18

        sec=(seg&0xF0)*10+seg&0x0F
        print(sec)
        

        will give you the correct int value

        1 Reply Last reply Reply Quote 1
        • robert-hhR Offline
          robert-hh @Lucas_Vieira
          last edited by

          @Lucas_Vieira @Eric73 Actually it should (could) be:
          sec = (segundos[0] >> 4) * 10 + (segundos[0] & 0x0f)
          or
          sec = (segundos[0] // 16) * 10 + (segundos[0] & 0x0f)
          The conversion to seg is not needed, since array access to a single bytearray element returns an integer.

          1 Reply Last reply Reply Quote 1
          • E Offline
            Elizar
            last edited by

            '\t' is the same code as '\x09', see https://theasciicode.com.ar/ascii-control-characters/horizontal-tab-ascii-code-9.html

            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
            • 1 / 1
            • First post
              Last post

            Pycom on Twitter

            Pycom