- Releases: https://github.com/IoTThinks/powersaving-arduino-lib/releases
- Powered by IoTThinks.com (8+ year in IoT / LoRa / LoRaWAN)
PowerSaving Arduino Core 2.0.17 is built for low power ESP32 boards.
- ESP32 boards with active BLE can reduced from 120mA down to 15-25mA.
- Based on Arduino Core 2.0.17 and IDF 4.4.7
- Power Management enabled
- BLE Sleep enabled
- Supports ESP32, ESP32S3 and ESP32C3.
- ESP32S2 is not supported yet due to low usage. If you need it, contact us at https://iotthinks.com/
- If you want custom development for your projects, Contact Us
- In platformio.ini, use the below in your
platform_packages = platformio/framework-arduinoespressif32@https://github.com/IoTThinks/powersaving-arduino-lib/releases/download/2.0.17/esp32-2.0.17.zip - In main.cpp, include the libraries
#include "esp_pm.h"
#include "esp_bt.h"
- In setup(), enable PowerSaving mode
// Enable BLE sleep
esp_err_t errBLESleep = esp_bt_sleep_enable();
if (errBLESleep == ESP_OK) {
Serial.println("Bluetooth sleep enabled successfully");
} else {
Serial.printf("Bluetooth sleep enable failed: %s\n", esp_err_to_name(errBLESleep));
}
#if CONFIG_IDF_TARGET_ESP32C3
esp_pm_config_esp32c3_t pm_config;
#elif CONFIG_IDF_TARGET_ESP32S3
esp_pm_config_esp32s3_t pm_config;
#elif CONFIG_IDF_TARGET_ESP32
esp_pm_config_esp32_t pm_config;
#endif
// Configure Power Management
pm_config = { .max_freq_mhz = 80, .min_freq_mhz = 40, .light_sleep_enable = true };
esp_err_t errPM = esp_pm_configure(&pm_config);
if (errPM == ESP_OK) {
Serial.println("Power Management configured successfully");
} else {
Serial.printf("Power Management failed to configure: %d\r\n", errPM);
}
- In loop, make some vTaskDelay() to let MCU have some time to sleep
vTaskDelay(pdMS_TO_TICKS(50)); // attempt to sleep
- Default PowerSaving for ESP32 companion BLE. Reduced from 120mA down to 15-25mA.