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

    M5StickC Plus MicroPython: Use GPIO 25 and 26 for I2C, 36 Floating

    Scheduled Pinned Locked Moved M5 Stick/StickC
    4 Posts 2 Posters 11.2k Views 1 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.
    • J Offline
      JackH
      last edited by

      Hi, I would like to use the GPIO 25 and 26 pins in the header for I2C, so I am setting them up as follows in MicroPython:

      from machine import Pin, I2C
      i2c = I2C(1, scl=Pin(26), sda=Pin(25), freq=400000)

      However, the description says that "G36/G25 share the same port, when one of the pins is used, the other pin should be set as a floating input" and provides the following example

      For example, to use the G36 pin as the ADC input, Configuration the G25 pin as FLOATING
      setup()
      {
      M5.begin();
      pinMode(36, INPUT);
      gpio_pulldown_dis(GPIO_NUM_25);
      gpio_pullup_dis(GPIO_NUM_25);
      }

      It seems that I should set GPIO36 to Floating. How does one do this in MicroPython, and where could one find such settings in the documentation? I have looked for a couple of hours and can't find this anywhere.

      Jack
      PS How do you create a code window on this board?

      1 Reply Last reply Reply Quote 0
      • felmueF Offline
        felmue
        last edited by felmue

        Hello Jack

        you could try the following to make GPIO36 floating:

        p36 = Pin(36, Pin.IN, None)
        

        Please note: I do not own a M5StickC Plus so I've tried above code on a M5Stack Fire. It runs without error.

        That said, I don't think GPIO36 has internal pull-up or pull-down circuitry to begin with since the following code did not change the voltage reading at all:

        p36 = Pin(36, Pin.IN, Pin.PULL_UP)
        

        BTW: When I define a pull-up for let's say GPIO25 the voltage goes up to about 3.2 volts as I would expect.

        For reference: https://docs.micropython.org/en/latest/library/machine.Pin.html

        Cheers
        Felix

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

        1 Reply Last reply Reply Quote 0
        • J Offline
          JackH
          last edited by

          Excellent, thank you very much Felix. And nice informative site you have there!

          May I ask how you ensure that MPU6886 is off in MicroPython?

          1 Reply Last reply Reply Quote 0
          • felmueF Offline
            felmue
            last edited by

            Hello Jack

            you are welcome and thank you.

            You'll need to check the MPU6886 datasheet

            There is a sleep mode bit (Bit 6) in register 107 (power management 1). When I read that register I get 0x01 which seems to be the default. To put MPU6886 into sleep mode I'd write 0x41 into that register like that:

            import i2c_bus
            i2c0 = i2c_bus.easyI2C(i2c_bus.PORTA, 0x68, freq=400000)
            i2c0.write_u8(107, 0x41)
            

            Thanks
            Felix

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

            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