Xiao-ESP32-S3 Sense Light Sleep Mode Issue

Hello Community,

I’m currently working with the Xiao-ESP32-S3 Sense module and encountering an issue with its light sleep mode. It seems that the ESP hangs when going into light sleep and never wakes up from timer, sometimes it gets a reset.
I also tried waking it up from GPIO and BLE, only deep sleep works.

Has anyone faced a similar issue or found a workaround?

This is the sketch - very simple:

#include <Arduino.h>

#include <esp_sleep.h>

void setup () {

Serial.begin(115200);

}

void loop () {

uint64_t sleepMicros = 850;

delay(100);

esp_sleep_enable_timer_wakeup(sleepMicros);

delay(100);

Serial.print("Sleeping: ");

Serial.println(sleepMicros);

delay(100);

uint32_t s = micros();

esp_light_sleep_start();

uint32_t e = micros();

Serial.print("Awake: ");

Serial.println(e - s);

delay(100);

}

this is the output from the serial monitor

10:25:03.758 → Sleeping: 850
10:25:03.758 → Awake: 1256
10:25:03.758 → Sleeping: 850
10:25:03.758 → Awake: 1087
10:25:03.758 → Sleeping: 850
10:25:03.758 → Awake: 1087
10:25:03.758 → Sleeping: 850
10:25:03.758 → Awake: 1086
10:25:03.758 → Sleeping: 850
10:25:03.758 → Awake: 1085
10:25:03.758 → Sleeping: 850
10:25:03.758 → Awake: 1087
10:25:03.758 → Sleeping: 850
10:25:40.724 → Sleeping: 850
10:25:40.724 → Awake: 1253
10:25:40.724 → Sleeping: 850
10:25:40.724 → Awake: 1082
10:25:40.724 → Sleeping: 850
10:25:40.724 → ESP-ROM:esp32s3-20210327
10:25:40.724 → Build:Mar 27 2021
10:25:40.724 → rst:0x15 (USB_UART_CHIP_RESET),boot:0x8 (SPI_FAST_FLASH_BOOT)
10:25:40.724 → Saved PC:0x4201f276
10:25:40.724 → SPIWP:0xee
10:25:40.724 → mode:DIO, clock div:1
10:25:40.724 → load:0x3fce3808,len:0x44c
10:25:40.724 → load:0x403c9700,len:0xbd8
10:25:40.724 → load:0x403cc700,len:0x2a80
10:25:40.724 → entry 0x403c98d0
10:25:41.018 → Sleeping: 850
10:25:41.090 → Awake: 1252
10:25:41.397 → Sleeping: 850
10:28:09.266 → eeping: 850
10:28:09.266 → Awake: 1081
10:28:09.266 → Sleeping: 850
10:28:09.266 → Awake: 1082
10:28:09.266 → Sleeping: 850
10:28:09.266 → Awake: 1082
10:28:09.266 → Sleeping: 850
10:28:09.266 → Awake: 1081
10:28:09.266 → Sleeping: 850
10:28:09.266 → Awake: 10811079
10:28:09.266 → Sleeping: 850
10:28:09.266 → Awake: 1079
10:28:09.266 → Sleeping: 850
10:28:09.266 → Awake: 1079
10:28:09.266 → Sleeping: 850
10:28:09.266 → Awake: 1079
10:28:09.266 → Sleeping: 850
10:28:09.266 → Awake: 1079
10:28:09.266 → Sleeping: 850
10:28:09.266 → ESP-ROM:esp32s3-20210327
10:28:09.266 → Build:Mar 27 2021
10:28:09.266 → rst:0x15 (USB_UART_CHIP_RESET),boot:0x8 (SPI_FAST_FLASH_BOOT)
10:28:09.266 → Saved PC:0x4201f276
10:28:09.266 → SPIWP:0xee
10:28:09.266 → mode:DIO, clock div:1
10:28:09.266 → load:0x3fce3808,len:0x44c
10:28:09.266 → load:0x403c9700,len:0xbd8
10:28:09.266 → load:0x403cc700,len:0x2a80
10:28:09.266 → entry 0x403c98d0
10:28:09.532 → Sleeping: 850

I appreciate any suggestions or guidance you can provide. Thank you for your time and assistance.

Hi there, and welcome,
So You could use the </> tags to post the code cleaner. FYI
SO I tried it and hangs after the delay’s stack up.
one note is this, When the ESP32 wakes up, it runs the whole code from the beginning.
It will come back to sleep once it reaches the line of code with the esp_deep_sleep_start(); function.
So, it will stay awake until running the esp_deep_sleep_start() function.
All your code should be placed before that function. More consistent results will be the outcome.
This works as It should.


// Light sleep
#include <Arduino.h>
#include <esp_sleep.h>

void setup () {

Serial.begin(9600);
delay (2000);
}

void loop () {
uint64_t sleepMicros = 500;
//delay(200);
esp_sleep_enable_timer_wakeup(sleepMicros);
//delay(200);
Serial.print("going to Sleep : ");
Serial.println(sleepMicros);
//delay(200);
uint32_t s = micros();
Serial.print("Awake: ");
uint32_t e = micros();
//delay(200);
Serial.println(e - s);
delay (500);
print_wakeup_reason();
esp_light_sleep_start();
//delay(1000);


}
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;
  }
}

Output Looks like this:

ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x15 (USB_UART_CHIP_RESET),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x4201e832
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3808,len:0x44c
load:0x403c9700,len:0xbe4
load:0x403cc700,len:0x2a38
entry 0x403c98d4
going to Sleep : 500
Awake: 12
Wakeup was not caused by deep sleep: 0
going to Sleep : 500
Awake: 12
Wakeup was not caused by deep sleep: 0
going to Sleep : 500
Awake: 12
Wakeup was not caused by deep sleep: 0
going to Sleep : 500
Awake: 12
Wakeup was not caused by deep sleep: 0
going to Sleep : 500
Awake: 11
Wakeup was not caused by deep sleep: 0
going to Sleep : 500
Awake: 11
Wakeup was not caused by deep sleep: 0
going to Sleep : 500
Awake: 12
Wakeup was not caused by deep sleep: 0
going to Sleep : 500
Awake: 11
Wakeup was not caused by deep sleep: 0
going to Sleep : 500
Awake: 11

HTH
GL :slight_smile: PJ :v:

Is there a way to awaken the ESP32S3 using a Bluetooth signal? I cant seem to find a way to do this.

I am also trying to awake ESP32S3 using a Bluetooth signal, no success atm.