M5.BtnA.wasPressed() conflicts with WiFi?

  • It appears that M5.BtnA.wasPressed() will not work properly if the M5Stack is currently connected via WiFi. I can't find any info on this so I'm posting it here to see if anyone knows anything about this and/or can duplicate what I'm seeing. (BtnB and BtnC work just fine with WiFi connected...)

    Is there some sort of resource conflict? It appears that BtnA can not be reliably used if the device is connected via WiFi. The pin appears to become unstable (no pullup/pulldown?) or maybe is being used for some other WiFi related function.

    Leave code below as is to see unstable BtnA. Comment out just the thyree WiFi connect lines to see BtnA working as expected:

    ----- Code Below ---------------

    #include <M5Stack.h>
    #include <WiFi.h>

    void setup(){

     // Comment out the next three lines for Button A to work properly
     WiFi.begin("SSID", "PWD");
     while (WiFi.status() != WL_CONNECTED) {


    void loop() {

     if(M5.BtnA.wasPressed()) M5.Lcd.println("Button A");


  • That is a bug present on the latest Arduino IDF. Install the previous Arduino IDF then will work just fine
    Here is an older version that work's just fine: https://github.com/espressif/arduino-esp32/tree/3a4ec66d41615cbb1c3e830cb6e761cdc4cca9d3

  • @Calin - this bug is reported as issue? I can't find it...

  • @reaper7M5.BtnA.wasPressed() conflicts with WiFi? 中说:

    @Calin - this bug is reported as issue? I can't find it...

    No... was not reported... i found it few days ago but i didn't report it...
    I solved the problem by overwriting the files from Arduino-idf installed on my pc with files from older version.
    You can report it to espresiff github repository if you want...
    When i will have some time i will investigate exactly what function cause this issue...

  • The problem can be solved with a delay(20); at the end of the loop() function. 10ms was not enough on my system, but 20 does not show any more ghost keystrokes.

  • Hello @hague

    nice find. Thank you for sharing the information.