M5stack BASIC v2.6 GPIO16 input problem



  • 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.



  • 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



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



  • 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



  • 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