void BeginSleep() { // SleepTimer = (SleepDuration * 60 - ((CurrentMin % SleepDuration) * 60 + CurrentSec)) + Delta; //Some ESP32 have a RTC that is too fast to maintain accurate time, so add an offset SleepTimer = SleepDuration * 60; esp_sleep_enable_timer_wakeup(SleepTimer * 1000000LL); // in Secs, 1000000LL converts to Secs as unit = 1uSec Serial.println("Entering " + String(SleepTimer) + " (secs) of sleep time"); Serial.println("Starting deep-sleep period..."); //esp_sleep_enable_ext1_wakeup(((uint64_t)(((uint64_t)1) << BUTTON_1)), ESP_EXT1_WAKEUP_ALL_LOW); //esp_sleep_enable_ext1_wakeup(((uint64_t)(((uint64_t)1) << BUTTON_2)), ESP_EXT1_WAKEUP_ALL_LOW); esp_sleep_enable_ext1_wakeup(BUTTON_PIN_BITMASK,ESP_EXT1_WAKEUP_ANY_HIGH); // esp_sleep_enable_touchpad_wakeup(); esp_deep_sleep_start(); // Sleep for e.g. 30 minutes } void print_GPIO_wake_up() { uint64_t GPIO_reason = esp_sleep_get_ext1_wakeup_status(); // Serial.print(GPIO_reason); Serial.print("GPIO that triggered the wake up: GPIO "); // "GPIO-контакт, ставший триггером пробуждения: GPIO" but=(log(GPIO_reason)) / log(2); // Serial.println((log(GPIO_reason)) / log(2), 0); if((but<37)||(but>39))but=0; Serial.println(but); if(but!=0)testSpeaker(); }