|
24 | 24 |
|
25 | 25 | #define BUTTON_PIN_BITMASK(GPIO) (1ULL << GPIO) // 2 ^ GPIO_NUMBER in hex
|
26 | 26 | #define USE_EXT0_WAKEUP 1 // 1 = EXT0 wakeup, 0 = EXT1 wakeup
|
| 27 | +#define WAKEUP_GPIO GPIO_NUM_33 // Only RTC GPIO are allowed - this is a ESP32 example |
27 | 28 | RTC_DATA_ATTR int bootCount = 0;
|
28 | 29 |
|
29 | 30 | /*
|
@@ -67,24 +68,24 @@ void setup() {
|
67 | 68 | RTC peripherals to be turned on.
|
68 | 69 | */
|
69 | 70 | #if USE_EXT0_WAKEUP
|
70 |
| - esp_sleep_enable_ext0_wakeup(GPIO_NUM_33, 1); //1 = High, 0 = Low |
| 71 | + esp_sleep_enable_ext0_wakeup(WAKEUP_GPIO, 1); //1 = High, 0 = Low |
71 | 72 | // Configure pullup/downs via RTCIO to tie wakeup pins to inactive level during deepsleep.
|
72 | 73 | // EXT0 resides in the same power domain (RTC_PERIPH) as the RTC IO pullup/downs.
|
73 | 74 | // No need to keep that power domain explicitly, unlike EXT1.
|
74 |
| - rtc_gpio_pullup_dis(GPIO_NUM_33); |
75 |
| - rtc_gpio_pulldown_en(GPIO_NUM_33); |
| 75 | + rtc_gpio_pullup_dis(WAKEUP_GPIO); |
| 76 | + rtc_gpio_pulldown_en(WAKEUP_GPIO); |
76 | 77 |
|
77 | 78 | #else // EXT1 WAKEUP
|
78 | 79 | //If you were to use ext1, you would use it like
|
79 |
| - esp_sleep_enable_ext1_wakeup_io(BUTTON_PIN_BITMASK(GPIO_NUM_33), ESP_EXT1_WAKEUP_ANY_HIGH); |
| 80 | + esp_sleep_enable_ext1_wakeup_io(BUTTON_PIN_BITMASK(WAKEUP_GPIO), ESP_EXT1_WAKEUP_ANY_HIGH); |
80 | 81 | /*
|
81 | 82 | If there are no external pull-up/downs, tie wakeup pins to inactive level with internal pull-up/downs via RTC IO
|
82 | 83 | during deepsleep. However, RTC IO relies on the RTC_PERIPH power domain. Keeping this power domain on will
|
83 | 84 | increase some power comsumption. However, if we turn off the RTC_PERIPH domain or if certain chips lack the RTC_PERIPH
|
84 | 85 | domain, we will use the HOLD feature to maintain the pull-up and pull-down on the pins during sleep.
|
85 | 86 | */
|
86 |
| - rtc_gpio_pulldown_en(GPIO_NUM_33); // GPIO33 is tie to GND in order to wake up in HIGH |
87 |
| - rtc_gpio_pullup_dis(GPIO_NUM_33); // Disable PULL_UP in order to allow it to wakeup on HIGH |
| 87 | + rtc_gpio_pulldown_en(WAKEUP_GPIO); // GPIO33 is tie to GND in order to wake up in HIGH |
| 88 | + rtc_gpio_pullup_dis(WAKEUP_GPIO); // Disable PULL_UP in order to allow it to wakeup on HIGH |
88 | 89 | #endif
|
89 | 90 | //Go to sleep now
|
90 | 91 | Serial.println("Going to sleep now");
|
|
0 commit comments