I've been experimenting with ESP8266 for a while, and have just got started looking into ESP32
The hardware setup is connecting an input pin to an SPDT switch (middle pin), and connect the other pins on the switch to VCC (3.3V) and GND:
(for some reason, I'm apparently unable to inline an image here... Please see the simple circuit at https://ibb.co/whySNGY)
I was able to configure an ext0 interrupt on either of these pins, but not on both at the same time. As I understand it, to do something like this you have to use the ESP-IDF API -- and not "only" the Arduino library. With some help from ChatGPT, I was able to set up this:
Code: Select all
#include <esp_sleep.h>
#include <driver/gpio.h>
void IRAM_ATTR handleInterrupt(void* arg) {
}
void setup()
{
Serial.begin(115200);
Serial.println("\nBoot");
// Initialize GPIO pins
gpio_config_t io_conf;
io_conf.intr_type = GPIO_INTR_ANYEDGE; // Interrupt on rising and falling edges
io_conf.pin_bit_mask = ((1ULL<<GPIO_NUM_25) | (1ULL<<GPIO_NUM_32));
io_conf.mode = GPIO_MODE_INPUT;
io_conf.pull_up_en = GPIO_PULLUP_DISABLE;
io_conf.pull_down_en = GPIO_PULLDOWN_ENABLE;
gpio_config(&io_conf);
// Install the ISR service with default configuration
gpio_install_isr_service(0);
// Hook ISR handler for specific GPIO pin
gpio_isr_handler_add(GPIO_NUM_25, handleInterrupt, NULL);
gpio_isr_handler_add(GPIO_NUM_32, handleInterrupt, NULL);
// Enable wake-up from external pin
esp_sleep_enable_ext1_wakeup(((1ULL<<GPIO_NUM_25) | (1ULL<<GPIO_NUM_32)), ESP_EXT1_WAKEUP_ANY_HIGH);
}
void loop() {
}
Am I right to expect a "wake up event" should do something like; run the ISR, run setup, and (possibly) run loop?