Hello,
I recently bought a Timer Camera board and have been using it with Arduino/PlatformIO. I had some issues trying to detect presses of the Power/Wake button in my code, and found several threads in this forum from people who apparently had the same issue. The problem is that the M5Stack docs have a table like this:
BUTTON | TimerCamera |
---|---|
BUTTON | G37 |
Button presses are definitely not registered on this pin.
By trial and error I attempted to read various pins and eventually found that the button pin is number 38
, and not 37
.
I used the gpio_*
functions from framework-arduinoespressif32
to read the pin; here's some sample code that should work:
#define BUTTON_PIN GPIO_NUM_38
void setup() {
Serial.begin(9600);
while (!Serial);
gpio_reset_pin(BUTTON_PIN);
gpio_set_direction(BUTTON_PIN, GPIO_MODE_INPUT);
gpio_set_pull_mode(BUTTON_PIN, GPIO_PULLUP_ONLY);
}
void loop() {
int button_state = gpio_get_level(BUTTON_PIN);
if (button_state == HIGH) {
Serial.println("Button pressed!");
}
}
I believe the Arduino pin functions would work too, e.g.
#define BUTTON_PIN GPIO_NUM_38
void setup() {
pinMode(BUTTON_PIN, INPUT);
}
void loop() {
int button_state = digitalRead(BUTTON_PIN); // HIGH when pressed
}
If someone from M5Stack reads this, could they please update the docs so that others can avoid spending time figuring this out? Or if someone knows how I could report this to them, I'd be happy to send them an email about it.
Here are the other threads I found about it, none with an answer unfortunately: