How to set ESP32 to low power mode?

I have ESPDUINO32 board with ESP-WROOM-32 module. I would like to turn modems (WiFi and Bluetooth) off, disable PSRAM and reduce CPU clock in order to save power. I’m fine with permanent setting on firmware upload, but API calls are preferable, if available. This video (Deep Sleep & Other Power Modes (ESP32 + Arduino Series) - YouTube) claims that the supply current can be reduced to 3mA without going to sleep mode:


I did a bit of search and couldn’t find a proper library. How can I accomplish this?

Modem sleep, deep sleep etc. capabilities are already built into the Arduino-ESP32 core, no special libraries needed. The core displays these example sketches for Deep Sleep. The function ESP.deepSleep() can also be used.

Per post, the core already implements modem sleep in its internal WiFi class. This is also accessible externally through WiFi.setSleep(), which is just a wrapper around the esp_wifi_set_ps function.

For the CPU frequency, the built-in function setCpuFrequencyMhz can be used. The core already automatically calls this function if F_CPU is set. Meaning that if you use build_flags like build_flags = -DF_CPU=8000000UL the core should try to set a 8MHz clock frequency – though at that low of a speed, things like UART at high baud rates might break. The function ESP.getCpuFreqMHz can be used to check if it worked.

I’m not looking for sleep modes. I would like to turn all modems off, but keep the CPU running at low frequency. Not sure that esp_wifi_set_ps(WIFI_PS_MIN_MODEM) turns all modems off, though.

Best to ask the Espressif people then in e.g. the Arduino core or their forum.