Skip to content

ESP32-C3 - Wake up from deep sleep zeroes RTC memory and will NOT report GPIO as a wake up cause #8341

@bricomp

Description

@bricomp

Board

WeActStudio.ESP32C3CoreBoard

Device Description

Dev board on plug in development

Hardware Configuration

Serial on 20&21.
IO on 4,5,6&7 connected to Teensy (either 3.1 or LC).
Shared ground with Teensy.
Both MCUs connected to USB

Version

latest master (checkout manually)

IDE Name

Arduino IDE

Operating System

Window 10

Flash frequency

80MHz

PSRAM enabled

yes

Upload speed

921600

Description

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

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions