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

    I2c repeated start question

    Scheduled Pinned Locked Moved MicroPython
    6 Posts 2 Posters 1.9k Views 2 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.
    • I Offline
      iotmaker
      last edited by

      i am getting funny values when i read back from registers i wrote.

      i am trying to get my accelerometer working and it is somehow kind of working .. i wonder if this could be a problem with micropython

      the datasheet says" The MMA8451Q expects repeated starts to be used to randomly read from specific registers."

      what does that mean? how can it affect normal micropython code?

      G 1 Reply Last reply Reply Quote 0
      • G Offline
        gertjanvanhethof Pybytes Beta @iotmaker
        last edited by

        @iotmaker Are you using clock stretching? This is not supported yet.

        Can you share your code? The information given is not enough to answer your question. 100th of options could cause the issue.

        1 Reply Last reply Reply Quote 0
        • I Offline
          iotmaker
          last edited by

          0_1487080788975_py1.png

          0_1487080799917_py2.png

          the datasheet has this diagram when you read a register the master send device address, register address and then a SR repeated start condition..

          i wonder if this is what the I2C library does in micropython?

          G 1 Reply Last reply Reply Quote 0
          • G Offline
            gertjanvanhethof Pybytes Beta @iotmaker
            last edited by

            @iotmaker The library is doing this correctly.
            You don't have to bother about ST, AK, SR, R, NAK and SP things.
            I'am not using the registers and using another I2C device.

            My code looks like this:

            data = i2c.readfrom(addr, 6)
            G 1 Reply Last reply Reply Quote 0
            • G Offline
              gertjanvanhethof Pybytes Beta @gertjanvanhethof
              last edited by

              But first you should send a command to start measuring.
              The data sheet should tell you which one.
              Command in my situation is:

              i2c.writeto(addr, bytearray(b'\x20\x24'))
              1 Reply Last reply Reply Quote 0
              • I Offline
                iotmaker
                last edited by

                Thanks

                looks like it is doing good now

                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