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

    M5stack BASIC v2.6 GPIO16 input problem

    Bases
    3
    5
    6.0k
    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.
    • K
      kazyam53
      last edited by

      I want to use GPIO16 on M5stack basic v2.6 as digital input but it doesn't work.
      I have tried on the code below but it always return 1.
      ・It's work well on M5 stack gray (default 0, when input 3.3V it return 1).
      ・In case I use GPIO17,25,26, it can also work well.
      ・I have 2 of basic v2.6 but both of them have same issue.

      This is the code I have tested.

      #include "Wire.h"
      #include <M5Stack.h>
      
      #define DIN 16
      void setup() {
        //start serial connection
        M5.begin();
        M5.Power.begin();
        Wire.begin();
        Serial.begin(9600);
        pinMode(DIN, INPUT_PULLDOWN);
      }
      
      void loop() {
        int sensorVal = digitalRead(DIN);
        Serial.println(sensorVal);
      }
      

      Do you have any solution or find issue on my code?
      Thank you in advance for your help.

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

        Hello @kazyam53

        M5Stack basic v2.6 seems to have some kind of pull-up resistor (about 3.3 k) on GPIO16. Not sure why and not sure why only on GPIO16.

        That said, you'll need to change your code to pinMode(DIN, INPUT_PULLUP); and then either leave GPIO16 open (reads 1) or connected to GND (read 0).

        Thanks
        Felix

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

        1 Reply Last reply Reply Quote 0
        • K
          kazyam53
          last edited by

          @felmue
          Then I need to change design... thank you so much for answer.

          1 Reply Last reply Reply Quote 0
          • M
            macsbug
            last edited by

            Hello @kazyam53

            M5Stack Basic V2.6

            There is a small clearance between the M-BUS and the metal surface on the back of the Speaker, and some are in contact with each other.
            There is a risk of short circuit of M-BUS (GND, 23,19,18,3,16,21).

            0_1655952413452_Unknown.jpeg

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

              Hello @macsbug

              I've noticed that too. However there is insulation (capton tape) on the back of the speaker in my M5Stack base v2.6.

              Thanks
              Felix

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

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