Reducing power consumption during wake-up

Hello, I am working with a Seeed XIAO nRF52840.

I'm able to get an average of 500 uA in SYSTEM OFF mode. However, for this application, the current consumption during wake-up is quite high (6mA plateau and then an 8 mA peak).

I would like to know if there is a way to reduce this consumption, right now I'm doing the programming in Arduino IDE using Bluefurit and AdafruitSPIFlash libraries. This is my code:

#include <bluefruit.h> // Necessary for Bluetooth communication
#include <Adafruit_SPIFlash.h>  // Necessary for FLASH memory management

Adafruit_FlashTransport_QSPI flashTransport; // Initialize flash communication device
Adafruit_SPIFlash flash(&flashTransport);

// Manufacturer IDs
#define XIAOMI_ID   0x0038F
#define APPLE_ID    0x004C

// Pin for sequential wake-up
#define WAKE_UP 2

// UUID for Beacon (fictional)
uint8_t beaconUuid[16] =
{
  0x01, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78,
  0x89, 0x9a, 0xab, 0xbc, 0xcd, 0xde, 0xef, 0xf0
};

// Beacon creation for advertising
BLEBeacon beacon(beaconUuid, 0x0102, 0x0304, -54);

// Optimized function for advertising
void start_advertising(void) {
  Bluefruit.Advertising.setBeacon(beacon);
  Bluefruit.ScanResponse.addName();

  // Increase interval for power savings
  Bluefruit.Advertising.setType(BLE_GAP_ADV_TYPE_NONCONNECTABLE_SCANNABLE_UNDIRECTED); // No connection allowed
  Bluefruit.Advertising.setInterval(160, 160); // Higher interval for power saving (units of 0.625ms)
  Bluefruit.Advertising.setFastTimeout(1);
  Bluefruit.Advertising.start(0); // Continuous advertising
}

// Optimized function for configuring clocks
void configure_clocks(void) {
  NRF_CLOCK->LFCLKSRC = CLOCK_LFCLKSRC_SRC_RC; // Use internal oscillator directly
  NRF_CLOCK->TASKS_LFCLKSTART = 1; // Start low-frequency clock
}

void setup() {

  // Enable DC/DC converters
  NRF_POWER->DCDCEN = 1;
  NRF_POWER->DCDCEN0 = 1;

  // Start low-frequency clock directly
  configure_clocks();

  // Initialize and put flash memory into deep sleep
  flashTransport.begin();
  flashTransport.runCommand(0xB9);  // Enter deep sleep mode
  flashTransport.end(); // End flash transport communication

  // Initialize Bluefruit library
  Bluefruit.begin();
  Bluefruit.setTxPower(0); // Keep TX power at -20dBm
  Bluefruit.autoConnLed(false); // Disable auto-connect LED

  // Low-power temperature reading
  int32_t temp = 0;
  sd_temp_get(&temp);
  int32_t real_temp = temp / 4;

  // Set manufacturer ID and populate beacon with temperature reading
  beacon.setMajorMinor(real_temp, 0);

  // Start advertising
  start_advertising();

  delay(20);

  // Configure GPIO for wake-up
  nrf_gpio_cfg_sense_input(WAKE_UP, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
  // Enter system-off mode for deep sleep

  NRF_POWER->SYSTEMOFF=1;
}

void loop() {
  // Empty loop
}

And this is the profile I see using the Power Profiler Kit 2 as source meter at 2200 mV:

  • Well, it is probably working as intended, but the application is not doing anything. It just powers itself off (system off mode) immediately after starting. So the last while(1); and return 0; are never reached

    Okay, I will look into the SDK examples that use SYSTEM OFF and check if they work as intended. I'll report back with the results.

    I suggest you check out some of the sample applications. I like the NCS\nrf\samples\bluetooth\peripheral_uart. Try building that, and see if you can see any advertisements using the nRF Connect for Android/iOS app. 

    I ran "multiple_adv_sets" not long after trying that SYSTEM OFF code I sent in the last reply, and received the data in both Android and iOS, so the BLE Stack is working alright.

    Thank you for your help, have a good weekend.

  • Looks like that Arduino stuff uses some kind of bootloader. And since SYSTEM OFF will always end in a full reset, it gets triggered every time the device wakes up, validates the firmware and waits for a pin to toggle, then starts the application code.

    You can see that the app runs with DCDC enabled causing less current consumtion.

    Its probably easier to switch to the NRF connect SDK than to try to fix the current consumtion with the Arduino libs.

Related