ESP32外部引脚通过内部上拉电阻唤醒

问题描述 投票:1回答:2

我很擅长使用Arduino和任何类型的电路。

我正在尝试使用命令esp_sleep_enable_ext0_wakeup设置ESP32板以使用外部触发器唤醒

void setup(){
    int MY_PIN = 13;
    pinMode(MY_PIN, INPUT_PULLUP);

    int reading = digitalRead(MY_PIN);
    if(reading == 1) {
        esp_sleep_enable_ext0_wakeup(GPIO_NUM_13,0);
    }
    else {
        esp_sleep_enable_ext0_wakeup(GPIO_NUM_13,1);
    }

    // I want the board to wake up every time the state of the switch changes.

    esp_deep_sleep_start();
}

我遇到了麻烦。当我期待它时,唤醒不会发生。我认为这与使用外部上拉电阻有关。我没有连接一个。

有没有办法为此目的使用内部上拉电阻?

我很感激能解释这一点如何运作的人。

documentation说:

@note此功能不会修改引脚配置。在进入睡眠模式之前,该引脚在esp_sleep_start中配置。

也许我需要使用esp_sleep_pd_config正确配置它。这可能是上拉电阻无法工作的原因吗?

arduino esp32
2个回答
© www.soinside.com 2019 - 2024. All rights reserved.