You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RTC variables are reset to zero when waking up from deep sleep, also esp_sleep_get_wakeup_cause() always returns zero.
The Teensy (3.1 or LC) is providing the reset signal.
Sketch
#define LED 8 // or use LED_BUILTIN for on-board LED
#define INTERRUPT_PIN 4
RTC_DATA_ATTR int bootCount; // = 0;
void setup() {
Serial.begin(115200);
delay(1000);
pinMode(LED, OUTPUT);
digitalWrite(LED, LOW);
++bootCount;
Serial.println("Boot number: " + String(bootCount));
print_wakeup_reason();
Serial.println("Going to blink the LED 10 times");
blink(10);
Serial.println("Going to sleep now");
Serial.flush(); delay(50);
esp_deep_sleep_enable_gpio_wakeup(1 << INTERRUPT_PIN,
ESP_GPIO_WAKEUP_GPIO_LOW);
esp_deep_sleep_start();
Serial.println("This will never be printed");
}
void loop() { }
void blink(int times) {
for (int i = 0; i < times; i++) {
digitalWrite(LED, HIGH);
delay(1000);
digitalWrite(LED, LOW);
delay(1000);
Serial.print("Blink ");
Serial.println(i + 1);
}
}
void print_wakeup_reason() {
esp_sleep_wakeup_cause_t wakeup_reason;
wakeup_reason = esp_sleep_get_wakeup_cause();
switch (wakeup_reason) {
case ESP_SLEEP_WAKEUP_EXT0:
Serial.println("Wakeup caused by external signal using RTC_IO");
break;
case ESP_SLEEP_WAKEUP_EXT1:
Serial.println("Wakeup caused by external signal using RTC_CNTL");
break;
case ESP_SLEEP_WAKEUP_TIMER:
Serial.println("Wakeup caused by timer");
break;
case ESP_SLEEP_WAKEUP_TOUCHPAD:
Serial.println("Wakeup caused by touchpad");
break;
case ESP_SLEEP_WAKEUP_ULP:
Serial.println("Wakeup caused by ULP program");
break;
default:
Serial.printf("Wakeup was not caused by deep sleep: %d\n", wakeup_reason);
break;
}
}
Debug Message
Port open
Boot number: 1
Wakeup was not caused by deep sleep: 0
Going to blink the LED 10 times
Blink 1
Blink 2
Blink 3
Blink 4
Blink 5
Blink 6
Blink 7
Blink 8
Blink 9
Blink 10
Going to sleep now
Port open
Boot number: 1
Wakeup was not caused by deep sleep: 0
Going to blink the LED 10 times
Blink 1
Blink 2
Blink 3
Blink 4
Blink 5
Blink 6
Blink 7
Blink 8
Blink 9
Blink 10
Going to sleep now
The text was updated successfully, but these errors were encountered:
RTC variables are reset to zero when waking up from deep sleep, also esp_sleep_get_wakeup_cause() always returns zero.
The Teensy (3.1 or LC) is providing the reset signal.
Sketch
Debug Message
The text was updated successfully, but these errors were encountered: