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

    M5.BtnA.wasPressed() conflicts with WiFi?

    PRODUCTS
    btna wifi
    7
    8
    17.2k
    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
      evanevery
      last edited by

      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(){

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

      }

      void loop() {

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

      }

      1 Reply Last reply Reply Quote 0
      • C
        Calin
        last edited by

        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

        1 Reply Last reply Reply Quote 1
        • reaper7R
          reaper7
          last edited by reaper7

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

          MY GITHUB: https://github.com/reaper7/

          C 1 Reply Last reply Reply Quote 0
          • C
            Calin @reaper7
            last edited by

            @reaper7 在 M5.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...

            1 Reply Last reply Reply Quote 1
            • hagueH
              hague
              last edited by

              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.

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

                Hello @hague

                nice find. Thank you for sharing the information.

                Thanks
                Felix

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

                1 Reply Last reply Reply Quote 0
                • F
                  febz11
                  last edited by

                  Solved it with adding:

                  WiFi.setSleep(false);
                  
                  1 Reply Last reply Reply Quote 0
                  • M
                    macsbug
                    last edited by macsbug

                    The cause is the ESP32 bug.

                    M5Stack Community :
                    M5.BtnA.wasPressed() conflicts with WiFi
                    https://forum.m5stack.com/topic/3262/m5-btna-waspressed-conflicts-with-wifi

                    This is a report of measures for the A button of M5Stack and the B button of M5Stick C to operate without permission.
                    ButtonA on M5Stack does not work properly : May 02, 2021

                    void setup(){
                    WiFi.begin();
                    WiFi.setSleep(false);
                    }

                    or

                    #include <driver/adc.h>
                    void setup(){
                    adc_power_acquire(); // ADC Power ON

                    :

                    blog :
                    ButtonA on M5Stack does not work properly : May 02, 2021
                    https://macsbug.wordpress.com/2021/05/02/buttona-on-m5stack-does-not-work-properly/

                    0_1673987001392_p.jpg

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