There are a ton of forum posts about the power consumption of the ESP32 while using BLE and why it's so high, the only reason I'm making this post at all is because they're all from years ago and most simply boil down to "the 'L' in BLE isn't a thing yet", but I can't find any follow up posts anywhere showing whether or not the BLE is still power hungry.
As far as things I've tried, I found this post: viewtopic.php?t=773 which suggests turning off the WiFi section of the radio module via
Code: Select all
esp_wifi_set_mode(WIFI_MODE_NULL);
Code: Select all
esp_wifi_stop();
I've powered off the ADC using
Code: Select all
adc_power_off();
I changed the CPU frequency as suggested here https://www.savjee.be/2019/12/esp32-tip ... lock-speed via the command
Code: Select all
setCpuFrequencyMhz(80);
My exact setup and testing results so far:
My board is the TinyPico (https://www.tinypico.com/), which conveniently had a very efficient lipo battery management circuit on board. To measure power usage I've connected an INA260 current sensor (https://learn.adafruit.com/adafruit-ina ... r-breakout) between the external battery and the BAT pin of the board. I'm only interested in two keys at the moment, so I have pins 32 and 33 pulled low via external resistors.
Running the code below, the best average current consumption I was able to achieve was around 33mA, which is better than a lot of posts I've read, but still pretty terrible for a BLE HID device.
Code: Select all
#include <TinyPICO.h> //for the TinyPico dev board
#include <BleKeyboard.h>
#include <driver/adc.h>
BleKeyboard bleKeyboard;
TinyPICO tp = TinyPICO();
//both pins are pulled low via external resistor
#define upButton 32
#define downButton 33
void setup() {
tp.DotStar_SetPower(false);
adc_power_off();
setCpuFrequencyMhz(80);
Serial.begin(115200);
Serial.println(getCpuFrequencyMhz());
bleKeyboard.begin();
pinMode(upButton, INPUT);
pinMode(downButton, INPUT);
Serial.print("Connecting...");
while(!bleKeyboard.isConnected());
Serial.println("Connected");
}
void loop() {
while(bleKeyboard.isConnected()) {
if(digitalRead(upButton)) {
bleKeyboard.press(KEY_UP_ARROW);
bleKeyboard.releaseAll();
delay(1000); //debouncing
}
if(digitalRead(downButton)) {
bleKeyboard.press(KEY_DOWN_ARROW);
bleKeyboard.releaseAll();
delay(1000);
}
delay(10);
}
delay(1000);
}
All that to say, is there anything I can do to reduce the power consumption of the ESP32 while using BLE? Something else I can turn off? A way to turn off WiFi while leaving BLE on? An example of how to use modem sleep?
Example code would be awesome, but links to other resources, and even just ideas are welcome as well.