ESP-C3 putting back to deep sleep keeps resetting
Posted: Sun Jun 19, 2022 2:51 pm
Hi,
I have a ESP32-C3 where i need to use the esp_wake_deep_sleep() stub to perform some tasks, and then return back to sleep, but every time i attempt to put it back to sleep, it just resets, and wakes up the system rather than returning to deep sleep,
I have simplified the code as much as possible and this code does not return back to sleep. It just keeps wakes up every 2 seconds.
This results in console output of :
I've been trying to resolve this for weeks now and not getting anywhere,
Please can anyone help
Thanks
I have a ESP32-C3 where i need to use the esp_wake_deep_sleep() stub to perform some tasks, and then return back to sleep, but every time i attempt to put it back to sleep, it just resets, and wakes up the system rather than returning to deep sleep,
I have simplified the code as much as possible and this code does not return back to sleep. It just keeps wakes up every 2 seconds.
Code: Select all
#include "esp32c3/rom/rtc.h"
/*
Simple Deep Sleep with Timer Wake Up for ESP32-C3
*/
#define uS_TO_S_FACTOR 1000000ULL /* Conversion factor for micro seconds to seconds */
#define TIME_TO_SLEEP 2 /* Time ESP32 will go to sleep (in seconds) */
RTC_DATA_ATTR int bootCount = 0;
RTC_DATA_ATTR int wakeupcount = 5;
void setup(){
Serial.begin(115200);
delay(1000); //Take some time to open up the Serial Monitor
Serial.println("Boot number: " + String(bootCount));
esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
Serial.println("Setup ESP32 to sleep for every " + String(TIME_TO_SLEEP) + " Seconds");
Serial.println("Going to sleep now");
Serial.flush();
esp_deep_sleep_start();
Serial.println("This will never be printed");
}
void RTC_IRAM_ATTR esp_wake_deep_sleep()
{
esp_default_wake_deep_sleep();
//Increment boot number
++bootCount;
// check to see if time to wakeup ,or go back to sleep
if (bootCount <= wakeupcount)
{
// Go to sleep.
set_rtc_memory_crc();
CLEAR_PERI_REG_MASK(RTC_CNTL_STATE0_REG, RTC_CNTL_SLEEP_EN);
SET_PERI_REG_MASK(RTC_CNTL_STATE0_REG, RTC_CNTL_SLEEP_EN);
// A few CPU cycles may be necessary for the sleep to start...
while (true) {
;
}
}
else
{
// wake up normally
return;
}
}
void loop(){
//This is not going to be called
}
This results in console output of :
Code: Select all
ESP-ROM:esp32c3-api1-20210207
Build:Feb 7 2021
rst:0x1 (POWERON),boot:0xd (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd6100,len:0x438
load:0x403ce000,len:0x90c
load:0x403d0000,len:0x2358
SHA-256 comparison failed:
Calculated: a9753a4fc647c6545c1b919ef08db429130a48592727edca270f1e5a3da0d0a9
Expected: 3bf6ef2cf3b9eefcd4b3c70cc5d1ce5138292d101a5cb1d5db6fbebf081b0a19
Attempting to boot anyway...
entry 0x403ce000
Boot number: 0
Setup ESP32 to sleep for every 2 Seconds
Going to sleep now
ESP-ROM:esp32c3-api1-20210207
Build:Fe⸮ESP-ROM:esp32c3-api1-20210207
Build:Feb 7 2021
rst:0x5 (DSLEEP),boot:0xd (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd6100,len:0x438
load:0x403ce000,len:0x90c
load:0x403d0000,len:0x2358
SHA-256 comparison failed:
Calculated: a9753a4fc647c6545c1b919ef08db429130a48592727edca270f1e5a3da0d0a9
Expected: 3bf6ef2cf3b9eefcd4b3c70cc5d1ce5138292d101a5cb1d5db6fbebf081b0a19
Attempting to boot anyway...
entry 0x403ce000
Boot number: 1
Setup ESP32 to sleep for every 2 Seconds
Going to sleep now
ESP-ROM:esp32c3-api1-20210207
Build:Fe⸮ESP-ROM:esp32c3-api1-20210207
Build:Feb 7 2021
rst:0x5 (DSLEEP),boot:0xd (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
Please can anyone help
Thanks