BLE Power Consumption Optimization

For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Charleszard
 
Posts: 7
Joined: Mon May 14, 2018 7:09 pm

BLE Power Consumption Optimization

Post by Charleszard »

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:
itsybitsy ble uart advertisement consumption
itsybitsy ble uart advertisement consumption
itsyBitsyBLEadvTest.png (62.64 KiB) Viewed 373 times

Code: Select all

#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.

User avatar
PWK
 
Posts: 39
Joined: Wed Mar 06, 2019 9:08 am

Re: BLE Power Consumption Optimization

Post by PWK »

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

User avatar
hathach
 
Posts: 1270
Joined: Tue Apr 23, 2013 1:02 am

Re: BLE Power Consumption Optimization

Post by hathach »

There is an issue with BANNED 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

Locked
Please be positive and constructive with your questions and comments.

Return to “Wireless: WiFi and Bluetooth”