Xiao ble sense power off

Hi there,

So , Comcast having Internet connectivity issues here,
I set up a test with this code and a Xiao nRF52840 Sense
BSP 1.1.10 non-mbed :grin: :+1:

I’m getting 12.6 uA sleep & 7ma. Awake.

#include <Arduino.h>
#include <bluefruit.h>
#include <Adafruit_FlashTransport.h>

long previousMillis = 0;  // last time the battery level was checked, in ms
Adafruit_FlashTransport_QSPI flashTransport;
void setup()
{
sd_power_mode_set(NRF_POWER_MODE_LOWPWR);
sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE);
__WFE();
__WFI();
sd_app_evt_wait() ; //SOFT DEVICE “SYSTEM ON” POWER SAVE

//NRF_POWER->SYSTEMOFF = 1;
}

void loop()
{
  long currentMillis = millis();
      // if 200ms have passed, check the battery level:
      if (currentMillis - previousMillis >= 80000)
      {
        previousMillis = currentMillis;
        shutdown();
      }
// currentMillis = millis();
      // if 200ms have passed, check the battery level:
      if (currentMillis - previousMillis >= 60000)
      {
        previousMillis = currentMillis;
        NRF_POWER->SYSTEMOFF = 1;
      }


}

void sleepFlash() {
    flashTransport.begin();
    flashTransport.runCommand(0xB9);
    flashTransport.end();
}

void disconnectPin(uint32_t ulPin) {
      if (ulPin >= PINS_COUNT) {
        return;
    }

    ulPin = g_ADigitalPinMap[ulPin];

    NRF_GPIO_Type * port = nrf_gpio_pin_port_decode(&ulPin);

    port->PIN_CNF[ulPin] = 
          ((uint32_t)GPIO_PIN_CNF_DIR_Input        << GPIO_PIN_CNF_DIR_Pos)
        | ((uint32_t)GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_INPUT_Pos)
        | ((uint32_t)GPIO_PIN_CNF_PULL_Disabled    << GPIO_PIN_CNF_PULL_Pos)
        | ((uint32_t)GPIO_PIN_CNF_DRIVE_S0S1       << GPIO_PIN_CNF_DRIVE_Pos)
        | ((uint32_t)GPIO_PIN_CNF_SENSE_Disabled   << GPIO_PIN_CNF_SENSE_Pos);
}

void shutdown() {
    //sleep flash
    sleepFlash();
    //disconnect any pins used
    disconnectPin(D1);
    disconnectPin(D2);
    //setup pin for wakeup
    nrf_gpio_cfg_sense_input(g_ADigitalPinMap[D3], NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
    //power off
    sd_power_system_off();
}

Below DUT :raised_hand_with_fingers_splayed:

HTH
GL :slight_smile: PJ :v:

2 Likes