0

BLE Power Consumption Optimization
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

BLE Power Consumption Optimization

by Charleszard on Thu May 27, 2021 4:23 pm

Hello all,

This is a problem I'm looking to tackle across various platforms that utilize the Bluefruit BLE library. Any and all help would be much appreciated.

Currently, no matter the platform (tested NRF52840 feather, itsybitsy NRF52840, NRF52832 feather, RAK4631 Core) that use this library, I cannot seem to get the microcontroller to deep sleep anymore in between operations once Bluefruit.begin() is called.

For the purposes of experimentation and my discussion I'm limiting the focus to the ItsyBitsy NRF52840, with a depopulated RGB LED to minimize power consumption. The device is being powered externally via a Nordic PPK2 on its 3V pin at 3300mV, the same kit is used for power consumption measurements.

For the firmware, I'm using a slightly modified BLE UART example with all print statements removed, using longer advertisement interval, and a hardcoded message ("hi") to be sent every 5s to the connected device on connection.

When running that sketch (pasted below) without connecting, the following consumption is found:

itsyBitsyBLEadvTest.png
itsybitsy ble uart advertisement consumption
itsyBitsyBLEadvTest.png (62.64 KiB) Viewed 271 times


Code: Select all | TOGGLE FULL SIZE
#include <Arduino.h>
#include <bluefruit.h>

// Forward declarations for functions
void ble_connect_callback(uint16_t conn_handle);
void ble_disconnect_callback(uint16_t conn_handle, uint8_t reason);

BLEUart g_BleUart;

bool g_BleUartConnected = false;

void setup()
{
    time_t timeout = millis(); // Timeout in case the system runs on its own

    Bluefruit.configPrphBandwidth(BANDWIDTH_MAX);
    Bluefruit.configPrphConn(92, BLE_GAP_EVENT_LENGTH_MIN, 16, 16);

    Bluefruit.begin(1, 0);
    // Set max power. Accepted values are: -40, -30, -20, -16, -12, -8, -4, 0, 4
    Bluefruit.setTxPower(4);
    // Set the BLE device name
    Bluefruit.setName("RAK4631_UART");

    Bluefruit.Periph.setConnectCallback(ble_connect_callback);
    Bluefruit.Periph.setDisconnectCallback(ble_disconnect_callback);
    Bluefruit.Periph.setConnInterval(16, 16); // min = 9*1.25=11.25 ms, max = 16*1.25=20ms

    // Configure and Start BLE Uart Service
    g_BleUart.begin();

    // Set up and start advertising
    // Advertising packet
    Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
    Bluefruit.Advertising.addTxPower();
    Bluefruit.Advertising.addName();

    Bluefruit.Advertising.restartOnDisconnect(true);
    Bluefruit.Advertising.setInterval(1952, 1952); // in unit of 0.625 ms
    Bluefruit.Advertising.setFastTimeout(30);   // number of seconds in fast mode
    Bluefruit.Advertising.start(0);             // 0 = Don't stop advertising after n seconds
}

void ble_connect_callback(uint16_t conn_handle)
{
    (void)conn_handle;
    g_BleUartConnected = true;

    //Serial.println("BLE client connected");
}

void ble_disconnect_callback(uint16_t conn_handle, uint8_t reason)
{
    (void)conn_handle;
    (void)reason;
    g_BleUartConnected = false;

    //Serial.println("BLE client disconnected");
}

void loop()
{
    // Forward anything received from USB Serial to BLE UART
    if (g_BleUartConnected)
    {
        g_BleUart.print("hi");
        delay(5*1000);
    }

    // Forward anything received from BLE UART to USB Serial
    if (g_BleUart.available())
    {
        //Serial.print(g_BleUart.readString());
    }
   
}


Does anyone have any insight into how to allow the microcontroller to sleep between advertisement intervals? Even if I get down to ~0.5mA I'd be happy for what I have in mind for my project. Any and all tips and insights would be appreciated.

Charleszard
 
Posts: 7
Joined: Mon May 14, 2018 7:09 pm

Re: BLE Power Consumption Optimization

by PWK on Thu Jun 03, 2021 12:36 pm

I use the NRF52832 but not in deep sleep and draw about 600 micro amps. I have had success with this command added to setup. sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE); // This saves power approx. 500 micro amps (.5 milli amps) Also this command
Serial.end(); // Shut this down to limit power. Hope this helps. There are many posts on the forum about power consumption.

Paul

PWK
 
Posts: 34
Joined: Wed Mar 06, 2019 9:08 am

Re: BLE Power Consumption Optimization

by hathach on Mon Jun 07, 2021 1:35 pm

There is an issue with crypto cell in recent release. Which has been fixed, you can follow the issue in git latest https://github.com/adafruit/Adafruit_nR ... issues/600

We will release an update soon enough, meanwhile. If you could try it out to see if that fix yours

hathach
 
Posts: 1151
Joined: Tue Apr 23, 2013 1:02 am

Please be positive and constructive with your questions and comments.