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(){
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();
}
-
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...
-
@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... -
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.
-
-
Solved it with adding:
WiFi.setSleep(false);
-
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-wifiThis 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, 2021void 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/