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 Pullup Resistors

    Scheduled Pinned Locked Moved Discussion
    i2c
    12 Posts 5 Posters 5.2k Views 5 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.
    • E Offline
      Eric24 @jmarcelino
      last edited by

      @jmarcelino OK (and understood about the input-only pins). Are the pullups automatically enabled by the I2C driver or must this be done manually?

      J 1 Reply Last reply Reply Quote 0
      • J Offline
        jmarcelino @Eric24
        last edited by jmarcelino

        @Eric24
        The pins are set to open drain, pull up automatically on calling I2C init:

        pin_config (self->scl, -1, -1, GPIO_MODE_INPUT_OUTPUT_OD, MACHPIN_PULL_UP, 1);
        pin_config (self->sda, -1, -1, GPIO_MODE_INPUT_OUTPUT_OD, MACHPIN_PULL_UP, 1);
        

        https://github.com/pycom/pycom-micropython-sigfox/blob/master/esp32/mods/machine_i2c.c#L135

        E 1 Reply Last reply Reply Quote 2
        • E Offline
          Eric24 @jmarcelino
          last edited by

          @jmarcelino Perfect. That was my assumption, but I wanted to be sure, in light of all the confusion over this in other forum posts.

          PS - This would be a good detail to include in the documentation.

          B 1 Reply Last reply Reply Quote 0
          • B Offline
            bucknall @Eric24
            last edited by

            @Eric24 @jmarcelino just seen this, logged it on my docs todo list! Thanks for handling this Jose :)

            Developer Evangelist - Pycom

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

              I don't mean to add more confusion but when experimenting with the I2C bus a couple of weeks ago I found that the internal pull up did NOT appear to be enabled when using pins other then P9 and P10.

              See this post.

              Are there differences in the way this is handled in different versions of the firmware?

              Mike T.

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

                @mike632t The internal pull-up resistors are a 'weak pull-up', meaning that they are good for a single device, short connections and moderate speed. If you face a situation, that the device works at low speed, bit not at high speed, add external pull-up resistors. The typical value is 4.7 kOhm. You need just one pair of resistors for the whole bus. If you use one of the convenient pre-assembled modules for sensors and other peripherals, check if they do not have already pull-up resistors populated. Often they have, for the convenience of the user. Then you might run into the opposite problem. If you connect too many of these modules, the total pull-up value may get too low.

                E 1 Reply Last reply Reply Quote 1
                • E Offline
                  Eric24 @robert-hh
                  last edited by

                  @robert-hh Do you happen to know the value of the internal pull-up resistors?

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

                    @Eric24 No. I made a quick static measurement, using a 33k resistor as load, and that indicated an internal pull-up of 22k. The confusing thing was, that the open port high output value was 2.56 V, when I expected 3.3 V. If I do my calculation against that 3.3 V, the result would be 38k for the internal pull-up. The other option would be to use an external capacitor as load and look at the time constant of the rising slope.

                    E 1 Reply Last reply Reply Quote 1
                    • E Offline
                      Eric24 @robert-hh
                      last edited by

                      @robert-hh Thanks for the effort!

                      @bucknall Alex: I've searched high and low for an answer to this (on the ESP32 as well) and it doesn't appear to be documented anywhere. This would be a really good think to know and not have to guess or experiment to find out.

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

                        @Eric24 For what it's worth, I repeated the test with a 10nF capacitor and a test code, which switches the output value high/low. To my surprise, the figure looks as if the capacitor is charged with a constant current. The calculation gave a current of ~47 µA, which matches the 1.53V seen across the 33k resistor.
                        0_1494346295478_10n_charge_opendrain.jpg

                        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