Skip to content

ESP32-C3 Deep Sleep Wake-up #8510

@abhi-sachdeva

Description

@abhi-sachdeva

Board

ESP32-C3-DevKit-M1

Device Description

Screenshot 2023-08-10 112523

The pull down resistor is 10kohms

Hardware Configuration

GPIO3 is the interrupt pin being used as a wake-up source

Version

latest master (checkout manually)

IDE Name

Arduino IDE

Operating System

Windows 10

Flash frequency

N/A

PSRAM enabled

yes

Upload speed

115200

Description

The ESP32-C3 will not wake up from deep sleep. I have reached out to other forums and have verified that the code works for them and is able to wake up the ESP32-C3. I do not know whether my problem lies in the breadboard or something else. I am using ESP32C3 Dev Module as the board and COM3 as the port on Arduino IDE. The serial output just states that "wakeup was not caused by deep sleep: 7" every time i push the button in attempt to wake the esp up. The boot number successfully increments after that. I will also provide the output (not serial monitor) below:

Screenshot 2023-08-10 113228

Sketch

#include "esp_sleep.h"
#include "driver/gpio.h"

#define INTERRUPT_PIN 3
RTC_DATA_ATTR int bootCount = 0;

void setup() {
  Serial.begin(115200);
  delay(1000);

  ++bootCount;
  Serial.println("Boot number: " + String(bootCount));

  print_wakeup_reason();

  Serial.println("Starting");
  delay(2000);
  
  for(int i=3; i!=0; i--){
      Serial.println(i);
      delay(1000);
  }

  Serial.println("Going to sleep now");

  pinMode(INTERRUPT_PIN, INPUT);
  esp_deep_sleep_enable_gpio_wakeup(1 << INTERRUPT_PIN, ESP_GPIO_WAKEUP_GPIO_HIGH);
  gpio_set_direction((gpio_num_t)INTERRUPT_PIN, GPIO_MODE_INPUT);  // <<<=== Add this line
  esp_deep_sleep_start();

  Serial.println("This will never be printed");
}

void loop() { }

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

ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5810,len:0x438
load:0x403cc710,len:0x918
load:0x403ce710,len:0x25f4
entry 0x403cc710
Boot number: 1
Wakeup was not caused by deep sleep: 0
Starting
3
2
1
Going to sleep now
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x5 (DSLEEP),boot:0xc (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5810,len:0x438
load:0x403cc710,len:0x918
load:0x403ce710,len:0x25f4
entry 0x403cc710
Boot number: 2
Wakeup was not caused by deep sleep: 7
Starting
3
2
1
Going to sleep now

Other Steps to Reproduce

Others have tried using my code and have said that it has worked for them, I do not know why it does not work for me! Also, taking away the resistor and wiring straight to ground brings up a message that says: "Not connected. Select a board and port to connect automatically."

Could it be an issue with a driver that I installed?

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

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions