XIAO BLE Sense in deep sleep mode

I am using their BLEUART BLEUart | Bluefruit nRF52 Feather Learning Guide | Adafruit Learning System

Added in these power savings measures as well:

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

Each LED will use about 0.3-1mA. So turn them off if not needed. The USB-C circuit will draw power eve if you have the chip shut down. So should measure the current at the battery. Without the battery and only using USB-C will not get down to uA.

Thanks for the report, I just played around with this for a while, I ended up using suspendLoop(); in Setup(); This gave me ~21 uA while advertising and around ~300-400 uA when connected.

With:

sd_power_mode_set(NRF_POWER_MODE_LOWPWR);
sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE);

I was stuck around 2-3 mA

Thanks for the feedback. It seems those are very good numbers for an active BLE connection. Yes, the effectiveness (or lack of) of the sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE) and ;sd_power_mode_set(NRF_POWER_MODE_LOWPWR); probably depends on how the circuit is physically built.

Hello @Citric,

Is there any updates on getting the deepsleep/Adafruit library working simultaneously with the IMU? As if I use ver 1.0.0 to get Adafruit working the IMU will not produce results. But if I use the latest firmware, the Adafruit library does not work but the IMU does.

Thank you

Currently R&D does not intend to continue with the development of deep sleep mode content.

Hi - do you have any example sketch that you may share?

I’d like to follow any recommendations on this too. The PCB dimensions of the Seeed Xiao series is really desirable for my project, other options tend to have more of a rectangular shape. I’ve just bricked by board, but have more arriving shortly. I plan to post some power measurements so as to gather some feedback from others that are clearly interested in battery powered projects.

Hello everyone.
I recently bought a XIAO BLE sense and wondered how to put the module in sleep mode. I found this post with the last post dated more than two months ago, but don’t see clear solution. The deep sleep demo code and the wiki page have never been updated.
I tried the deep_Sleep demo.ino with installing the Adafruit libraries and boards, but still get an error as shown below.
deep_Sleep_demo:31:6: error: #error No QSPI/SPI flash are defined on your board variant.h !
#error No QSPI/SPI flash are defined on your board variant.h !
What am I missing?
Other than this demo program, has any other solution been developed?

BTW, Seeedstudio should do actual technical support, not relying on figure-it-out-yourselves through this user’s forum.

Thank you.

You must use version 1.0 (Adafruit) of the firmware in the Arduino IDE. Looks like your board variant file is not what the demo program is looking for.

Makes sure you have a softdevice installed (should be shipped that way)
Use this on top of the code before setup():

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

Use this in the loop()
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

and when ready, shut it down with this:

NRF_POWER->SYSTEMOFF = 1;

or this:

sd_power_system_off();

1 Like

@fe7565 Thank you so much for your reply. I will give it a try and report back with results.
Thanks.

UPDATE: YES, it works now. Thanks again fe7565! In the deep sleep mode, it draws about 20uA.

1 Like

Hi, were you able to use ArduinoBLE library with the Seeed nRF52 mbed-enabled Boards version 1.0.0? I am having trouble running the library now as it shows I have other missing libraries in the include section of the ArduinoBLE library

C:\Users\XXXX\Documents\Arduino\libraries\ArduinoBLE\src\utility\HCICordioTransport.cpp:23:10: fatal error: mbed.h: No such file or directory
23 | #include <mbed.h>
| ^~~~~~~~
compilation terminated.
exit status 1
Error compiling for board Seeed XIAO nRF52840 Sense.

Unless things changed you cannot use version 1.0 with Mbed programs. Version 1.0 works only with Adafruit.

1 Like

hey, you mind sharing an example of your code with deep sleep working? i have been completely unsuccessful in getting it to work myself

Here is my code that’s what fe7565 explained in reply #68.

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

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()
{
}

Important thing is NOT to select ‘Seeed nRF52 mbed-enabled Board’, but to select ‘Seeed nRF52 Board’.

2 Likes

@hichiaty & @turing-complete-labs, how did y’all manage to get down to 3-5uA ?? With sd_power_system_off(), it only reaches around 20uA for me (and some other folks here in this thread). I am using regular (not Sense) Xiao BLE.

I followed these steps:

  1. Flashed this bootloader
    BLE_52840_Core/update-Seeed_XIAO_nRF52840_bootloader-0.6.1_nosd.uf2 at main · 0hotpotman0/BLE_52840_Core · GitHub

  2. Installed this library
    image

  3. Used this (minimal) code

void setup()
{
  suspendLoop();
  sd_power_system_off();
}

void loop()
{

}
  1. Measured current using GND and 3V3 pins

What could I possibly be missing ??

Note that adding the following to setup did not improve the sleep current (since I am using sd_power_system_off() anyway)

  sd_power_mode_set(NRF_POWER_MODE_LOWPWR);
  sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE);
  __WFE();
  __WFI();
1 Like

We have now discarded the original XIAO BLE on-board package (as you experienced, it was very confusing). Some time ago, we updated the new XIAO BLE on-board package. You guys can update the on-board package according to our wiki.

We divided into two XIAO BLE on-board packages, their application scope is different, we have marked which on-board package should be used in front of each case, you can then refer to the content of XIAO BLE low-power mode using the new on-board package to retry again.

How do you wake back up from sleep? I tried using nrf_gpio_cfg_sense_input() to no avail.

#include <Arduino.h>
#include <Wire.h>

#define wake_button 10

void setup()
{
  Serial.begin(115200);
  while(!Serial);
  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

  pinMode(wake_button, INPUT);
  attachInterrupt(digitalPinToInterrupt(wake_button), ISR_WAKE, RISING);
}

void loop()
{
  delay(10000);
  nrf_gpio_cfg_sense_input(wake_button, NRF_GPIO_PIN_PULLDOWN, NRF_GPIO_PIN_SENSE_HIGH);
  Serial.println("SLeeping");
  delay(100);
  NRF_POWER->SYSTEMOFF = 1;
}

void ISR_WAKE(){
  
}
1 Like

After messing around with the board for most of today I can share how to get the power down to a sensible level. I am currently at ~2uA in deep sleep, 3-4uA in light running (e.g. suspendLoop or delay).

Everyone who was stuck at ~20uA, the problem is there is a QSPI flash chip (P25Q16H) that remains powered when powering down the NRF and does not go into deep sleep itself. This flash chip sits there and draws ~18uA all the time. To put it into deep sleep you need to send the command 0xB9 to it.

#include <Adafruit_FlashTransport.h>

Adafruit_FlashTransport_QSPI flashTransport;

//start bluefruit (this also starts the soft device if you don't start the sd then none of your sd_* calls will do anything
Bluefruit.begin();
//before you put the NRF to sleep put the flash to sleep
flashTransport.begin();
flashTransport.runCommand(0xB9);
flashTransport.end();

//map a pin for wakeup 
nrf_gpio_cfg_sense_input(g_ADigitalPinMap[D3], NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
//shutdown
sd_power_system_off();

This will leave the flash in deepsleep next time you wake up the NRF, the command from the data sheet to turn it back on is 0xAB but I haven’t played with it yet. I used the adafruit sdfat fork to send in the qspi commands as it is much simpler than interfacing with the qspi hardware directly.

lib_deps =

    adafruit/Adafruit SPIFlash@^4.0.0

    adafruit/SdFat - Adafruit Fork@^2.2.1

Deep sleep with flash also in deep sleep:

6 Likes

NRF running with flash on standby at 20uA, then switching flash to deep sleep (note NRF is still running code)

2 Likes

Excellent! Thank you. I was ok with 20uA for my project, but I am excited that maybe I am able to use the QSPI for persistent memory. I need to change a value of a variable and make that changed variable available after a hard reboot. I think I found a complicated work-around, but using the QSPI would be much better. Any suggestions for the Arduino IDE? I do not use Python.