Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32S3: ESP-IDF light_sleep and deep_sleep examples bundled to IDF do not work (IDFGH-7286) #8875

Closed
idea--list opened this issue May 1, 2022 · 11 comments
Labels
Awaiting Response awaiting a response from the author Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally

Comments

@idea--list
Copy link

idea--list commented May 1, 2022

Environment

  • Development Kit: Adafruit ESP32S3 Feather

  • IDF version: V4.4.1

  • Build System: idf.py

  • Compiler version: xtensa-esp32-elf-gcc V8.4.0

  • Operating System: Windows 10 x64

  • (Windows only) environment type: ESP Command Prompt

  • Power Supply: USB

Problem Description

On Adafruit ESP32S3 Feather board light_sleep and deep_sleep examples bundled to ESP-IDF compile, flash, but do not work as expected. Power consumption remains high and constant.

On an old ESP32 board both examples work as expected.

Interestingly using Arduino IDE V1.8.19, esp32 core V2.0.3-RC1, esp_sleep_enable_timer_wakeup() and esp_light_sleep_start() or esp_deep_sleep_start() i can reach the expected power consumptions even on the Adafruit ESP32S3 Feather board

Expected Behavior

Low power consumptions with ESP-IDF on the new ESP32S3 chip

Actual Behavior

My ESP32S3 board does not seem to enter ligt or deep sleep states

Steps to reproduce

  1. compile&flash the light_sleep or deep_sleep examples delivered with ESP-IDF V4.4.1 on an ESP32S3 target
  2. monitor power consumption
@espressif-bot espressif-bot added the Status: Opened Issue is new label May 1, 2022
@github-actions github-actions bot changed the title ESP32S3: ESP-IDF light_sleep and deep_sleep examples bundled to IDF do not work ESP32S3: ESP-IDF light_sleep and deep_sleep examples bundled to IDF do not work (IDFGH-7286) May 1, 2022
@idea--list
Copy link
Author

Interestingly enough if i delete most conditional parts of the bundled examples until only these lines remain, then the ESP32S3 board behaves as expected and also the amp meter shows low consumption:


   This example code is in the Public Domain (or CC0 licensed, at your option.)

   Unless required by applicable law or agreed to in writing, this
   software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
   CONDITIONS OF ANY KIND, either express or implied.
*/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#include "sdkconfig.h"
#include "soc/soc_caps.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_sleep.h"
#include "esp_log.h"
#include "driver/adc.h"
#include "driver/rtc_io.h"
#include "soc/rtc.h"

void app_main(void)
{

    const int wakeup_time_sec = 10;
    printf("Enabling timer wakeup, %ds\n", wakeup_time_sec);
    esp_sleep_enable_timer_wakeup(wakeup_time_sec * 1000000);

    printf("Entering deep sleep\n");

    esp_deep_sleep_start();
}

@idea--list
Copy link
Author

Hmmm... after flashing the above modified code once and reverting back to the original examples, also the original examplex work now on the ESP32S3 board.

This really puzzles me 🤔

@igrr
Copy link
Member

igrr commented May 5, 2022

@idea--list did you manage to reproduce the issue again? Have tried the examples on an ESP32-S3 devkit, and both seem to be working...

Note that the ESP32-S3 DevKit-C board also has a CP2102 chip and an addressable LED. Both will continue to consume current when ESP32-S3 goes into deep sleep. It is better to use an ESP32-S3 module (instead of a devkit) to evaluate current consumption in deep sleep.

@xiaojie76
Copy link
Collaborator

Hi @idea--list, did you reproduce the issue again?

@Alvin1Zhang Alvin1Zhang added the Awaiting Response awaiting a response from the author label May 24, 2022
@idea--list
Copy link
Author

idea--list commented May 24, 2022

@igrr
Today i tried the original light sleep and deep sleep examples that ship with esp-idf again.
On my old ESP32 board both behave as expected. On my ESP32S3 board (Adafruit ESP32S3 Feather) only the deep sleep example behaves as expected.

When running the light sleep example on my ESP32S3 board i need to change BUTTON_GPIO_NUM_DEFAULT to let's say 12, but even after doing so, the power consumption drops to the expected level only while that pin is pulled up by connecting to the 3V3 pin. As soon as i disconnect pin 12 from 3V3, the power consumption increases to about 34mA without waiting until the sleep times out as set in line 50 of the example.

Do not know if this might be related somehow with espressif/arduino-esp32#6612, but it seems to me the light sleep example might need some revision.

@igrr
Copy link
Member

igrr commented May 24, 2022

@idea--list I think the wakeup GPIO should indeed be pulled up externally, so that it doesn't float while the chip is in sleep mode and doesn't cause accidental wakeup. For the default GPIO 0 (which is usually connected to "Boot" button on ESP boards), this is already the case. However there might be no pullup resistor on GPIO12 on your development board.

@idea--list
Copy link
Author

idea--list commented May 24, 2022

@igrr
I can not really debug this further as i am new to esp-idf and because of espressif/arduino-esp32#6612 my board simply can not output any messages after going to light sleep (as i am using windows).

I am not sure if my finding would be related to a possible floating of pin 12. As if that would be the case, i guess my board would output "Entering light sleep" at random intervals. However my observation is that after seeing the terminal output "Waiting for GPIO 12 to go high..." i can wait however long i wish before pulling that pin up that leads to "Entering light sleep" output, where i lose any further output because of espressif/arduino-esp32#6612. I guess if this was a floating pin issue, my observation would be something else.

@igrr
Copy link
Member

igrr commented May 24, 2022

However my observation is that after seeing the terminal output "Waiting for GPIO 12 to go high..." i can wait however long i wish before pulling that pin up that leads to "Entering light sleep" output

Sorry that I wasn't clear. By "floating" I meant "high-impedance input not driven to any specific logic level". Maybe there is some very week pulldown on the pin which makes it default to low state. Because the pin reads back as "low", the example doesn't enter sleep until it sees high logic level on the pin. Connecting the pin to 3.3V makes the example proceed and enter the sleep mode.

where i lose any further output because of espressif/arduino-esp32#6612.

Yes, I think that's one of the limitations of the built-in USB_SERIAL_JTAG peripheral, that it is suspended during light sleep, and USB connectivity gets broken. The root cause of this issue is #8507 — it will need to be fixed in IDF first and then the fix should be pulled into Arduino. In the meantime, please try using UART as console output when developing sleep related features.

@RS2021baseapp
Copy link

i am using esp32s3 in a custom board without any other component and trying the deep sleep example code.in this mode the current consumption will be 160uA. But in the datasheet only 7uA is mentioned.why esp32s3 is consuming this much amount of current in deep sleep mode??

Screenshot from 2022-08-26 17-44-40

@xiaojie76
Copy link
Collaborator

@idea--list @RS2021baseapp did you reproduce this issue again?

@espressif-bot espressif-bot added Status: Reviewing Issue is being reviewed and removed Status: Opened Issue is new labels Mar 31, 2023
@espressif-bot espressif-bot added Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally and removed Status: Reviewing Issue is being reviewed labels Apr 14, 2023
@Alvin1Zhang
Copy link
Collaborator

Thanks for reporting, will close due to short of feedback, feel free to reopen with more updates. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Response awaiting a response from the author Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally
Projects
None yet
Development

No branches or pull requests

6 participants