ESP32 sleep mode with wifi/BLE

for my new project, im looking for some possibilities to establish a connection between smartphone/tablet and the esp32 with the primary goal, to keep the power consumption of the esp32 as low as possible. My idea is to create a simple smartphone app which communicates with the esp32, to read some values or to do some controlling stuff (light on/off, select color...). It could be a webserver based application or an BLE android app, so im open with wifi and bluetooth.

The only thing: the esp32 is my server and if I want to use wifi, the ESP32 will work in AP mode. I found a solution where the esp32 is switching between active mode and modem sleep while the connection is still active (DTIM beacon mechanism). But this was only for wifi and only if the esp32 is in sta mode. Unfortunately I could not find any information, how much power could be saved with this method.

My client (tablet) is always close to the esp32 and the connection actually only needs to be establish if I unlock my screen and start the app. But how can I tell the esp32: "hello server, im ready for a connection, please wake up and start ble or wifi". The client could also be connected to the server all the time but it would be great to save some power like with the example with the DTIM beacons..

Are there any other solutions?

Thank you very much

The ESP32 has 2 micro processors. The main processor, that ‘everyone’ typically uses, has 2 cores. The other processor is called the ULP, Ultra Low Power. The ULP can be programmed to run and do the thing whiles the main core is asleep.

The ULP can be programmed from the Arduino IDE using macro code.

The documentation indicates that the ULP has 2 RAM storage spaces, RTC_FAST and RTC_SLOW. The documentation claims the ULP has 8K of ram available. Under the Arduino IDE the ULP only has 2K of 32 bit address for RTC_RAM.

The ULP Coprocessor (Legacy GNU Make) will do what you want.

Hi Idahowalker,
thank your for your answer. I think the ULP wont work. Im using different sleep modes in my older projects but the radio (wifi/bluetooth) always turns off. There is no chance to wake the main core with bluetooth and an usual setup. The ULP can only wake up the main core e.g. with timer and external gpio events. Or is there anything new? In the API reference I found one command:

esp_err_t esp_sleep_enable_wifi_wakeup (void)

This one enables WiFi by Wifi Mac. For me, its not clear what it means and how it works. There is no documentation about this.
I found one method to keep a wifi connection active during modem sleep (wakes up periodically), if the esp32 is in sta mode and the ap is properly configured. If im using wifi, the esp32 will be in AP mode, so that is not an option for me. It is described in the API guide - Wifi Driver - ESP32 Power Saving Mode.

I think there is no solution with wifi in AP mode and any power saving options. But what about bluetooth? I found one issue at github with a good solution:

Feature: Bluetooth modem sleep with external 32.768kHz xtal under light sleep

That is acutally what I need. One client is connected to the esp32. If there is no traffic between server and client, the esp32 is going to light sleep. If the client request something, the esp32 switches to active mode. For that, you will need an external 32 kHz oscillator, which I have. Now im running into trouble with the ESP-IDF configuration. Im using the Arduino IDE with Platform IO and dont have any idea where to change the settings.

Have you talked to the people at who make the ESP32?

yes, i wrote in the forum and my post is under review :wink: