Low power with Xiao nrf52840 on Zephyr RTOS

Hey @daCoder,

I have been following your answers for a few weeks now, and could really use your help with the following:

What I need to do: Using the Xiao nRF52840 Sense board, I want to put the system into deep sleep (lowest current consumption possible), and have it wake up and start advertising (as a beacon) when the IMU detects movement.

My setup: Seeed studio nRG52840 Sense board with board firmware v1.0 (for deep sleep support), non-embedded version.

What I’ve achieved so far: I am able to implement BLE advertising along with deep sleep. For example, I can make the board advertise for 30 seconds, then put it to sleep with a digital pin interrupt for wake-up. During sleep it consumes ~2-4 uA. I can successfully wake the device up by providing input (LOW in my case) to a Digital I/O pin.

Problem: I am facing two problems when adding the IMU component to it: a) The board is consuming ~800uA even when it’s supposed to be in the sleep state, and b) something keeps waking up the device instantly. I have provided a basic code example below. Can you please help me add the IMU interrupt to it so that it consumes low power in sleep state and successfully wakes up when IMU detects ‘x’ threshold of movement?

Thank you so much!!
Sheep Boi

Code:

#include <Adafruit_FlashTransport.h>

#include <bluefruit.h>

#include “LSM6DS3.h”

#include “Wire.h”

#include <Arduino.h>

#include <Adafruit_SPIFlash.h>

#define MANUFACTURER_ID 0x0059

Adafruit_FlashTransport_QSPI flashTransport;

int ble_enabled = 0;

int work_LED_status = HIGH;

uint8_t beaconUuid[16] =

{

0x01, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78,

0x89, 0x9a, 0xab, 0xbc, 0xcd, 0xde, 0xef, 0xf0

};

// A valid Beacon packet consists of the following information:

// UUID, Major, Minor, RSSI @ 1M

BLEBeacon beacon(beaconUuid, 0x0102, 0x0304, -4);

void setup() {

Bluefruit.begin();

Bluefruit.setName(“board1”);

Bluefruit.setTxPower(0);

Bluefruit.autoConnLed(false);

beacon.setManufacturer(MANUFACTURER_ID);

delay(3000);

flashTransport.begin();

flashTransport.runCommand(0xB9);

flashTransport.end();

//nrf_gpio_cfg_sense_input(g_ADigitalPinMap[D3], NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);

Bluefruit.Advertising.setBeacon(beacon);

Bluefruit.ScanResponse.addName();

// Start Advertising

void loop(){

delay(20000);

//

sd_power_system_off();

}

1 Like