System_ON_Sleep of XIAO BLE

Update but leaving it in here for reference, if someone else is wondering:
I just realised while scrolling back trough the postings that you are directly supplying 3.3v to the pins instead of the vbat pads on the back.
I guess this is the reasons and we cannot get lower when using the vbat pads…

Hello msfujino,
i am trying to get my Seeed Xiao NRF52840 non-mbed to use as little power as possible for a battery operated project which will use bluefruit ble as a client.

I used your sketch from 07.07.2023 as the basis to create a bare minimum blink sketch to get some baseline data.

However with i can only get down to 0.14 mA in the delay (measured with a rough resolving 0.00mA multimeter) - 0.41 with blue led blinking.

Did you undertake measures to disable the small charging led on the Seeed Xiao nrf52840?

Thanks a lot

nRF52_XIAO_LightSleep_freertos_delay_blink.zip (1,1 KB)

Hi 1melc,
I measured the current using your sketch. 3.6V is applied to the battery pad on the back. It is about 4.6uA when the LED is off and about 150uA when the LED is on.

Hi there,
Thanks a Lot!
Looks like i have to get myself a PowerProfilerKit :slight_smile:

WoW,
So who knew, The Interrupt method also effect the sleep, If you use an edge (RISING/FALLING)it uses more current during sleep to maintain the trigger gate, If you use a level (LOW) it uses less current in sleep?? mode.
Here is an Old video demo with a PPK as well worth the View.

Who Knew?
HTH
GL :slight_smile: PJ :v:

I can’t, for the life of me, reach 4uA idle current.

Everything works, but my XIAO BLE Sense consumes 4mA and that’s it,

Any idea what is going on??

Hi iggzzzz,
The following link may be helpful.
Sleep Current of XIAO nRF52840, Deep Sleep vs. Light Sleep

If you give me enough information, I can try to reproduce your measurements.

OK, let me know what info you need?

My target is to achive light sleep, for my LoRa node.

for my LoRa node

What exactly is XIAO BLE’s LoRa node?
Show me your setup(connection) and 4mA sketch.
Can you also tell me how you measure current?

It’s a motherboard with LoRa transciever with an XIAO BLE Sense soldered to it. Still waiting for the motherboard.

I use an Aneng AN870 multimeter, verifieg good uA measurement.

//----------------------------------------------------------------------------------------------
// BSP : Seeed nRF52 Borads 1.1.1
// Board : Seeed nRF52 Boards / Seeed XIAO nRF52840 Sense
// important : need for Serial.print() <Arduino.h> <Adafruit_TinyUSB.h>
// \Arduino15\packages\Seeeduino\hardware\nrf52\1.1.1\libraries\Bluefruit52Lib\src
//----------------------------------------------------------------------------------------------

// 2023/07/07
// Central sketch : nRF52_XIAO_LightSleepAdvScan_central.ino
// Need to be deleted /Documents/Arduino/libraries/SdFat

#include <Arduino.h>
#include <Adafruit_TinyUSB.h>   // For Serial.print()
#include <bluefruit.h>          // \Arduino15\packages\Seeeduino\hardware\nrf52\1.1.1\libraries\Bluefruit52Lib\src
#include <Adafruit_SPIFlash.h>  // Need to be deleted /Documents/Arduino/libraries/SdFat

#define SLEEP_TIME 30   // Sleep time [sec]

Adafruit_FlashTransport_QSPI flashTransport;

uint8_t timeout = 5;

void setup() {
  // Serial port initialization
  Serial.begin(115200);
  while ((!Serial) && (timeout)){
      delay(1000);
      timeout--;
  }

  // Enable DC-DC converter
  NRF_POWER->DCDCEN = 1;  // Enable DC/DC converter for REG1 stage

  // Sleep QSPI flash
  flashTransport.begin();
  flashTransport.runCommand(0xB9);  // enter deep power-down mode
  flashTransport.end();

  // Initialization of Bruefruit class
  Bluefruit.begin();
  Bluefruit.setTxPower(4);  // Check bluefruit.h:151 for supported values
  Bluefruit.autoConnLed(false); // turn off LED to save power   Sleep Current 4uA
//  Bluefruit.setConnLedInterval(50); // Should not be used, Sleep current 300uA

  Serial.println("End of initialization");
}

//*************************************************************************************************************
void loop() {

  digitalWrite(LED_BLUE, LOW);  // turn the LED on (HIGH is the voltage level)
  delay(5000);                      // light for 5 seconds, but the rtc in the background keeps running. --> light off only for 25 seconds
  digitalWrite(LED_BLUE, HIGH);  

  delay(SLEEP_TIME * 1000);           // System ON Sleep by FreeRTOS

}

Is it possible my SoftDevice aint working?

I use an Aneng AN870 multimeter, verifieg good uA measurement.

Do you run this sketch and the measured value is 4mA?
Where is the multimeter connected?
Are you aware that this multimeter can only measure average current?
Is there anything connected to the XIAO port that could be a load?

Yes. Isupply Vusb with 5V and it consumes 4mA. XIAO BLE Sense is the only thing I have right now. Nothing else besides it, so no load of any kind, no pins connected to anything.

If I supply through battery side, the consumption is OK. So I think supplying it through Vusb will always consume 4mA?

I supply Vusb with 5V

Are you supplying 5V from XIAO’s USB-C connector?
Are you supplying 5V from the 5V pin of the XIAO?
Where is the multimeter connected?

I will try to measure the current with the sketch you posted.

edit
I am trying to compile your sketch, but I get a lot of errors in my environment and cannot compile it.
It may take some time to investigate.

If you remove the lines about Flash and BLE, will the current consumption decrease? Can you measure it?

It is solved. Supplying it through battery is OK, supplying it from +5V Vusb pin causes 4mA consumption.

I am already working on my application.

Good for you.
The on-board battery charge controller consumes a lot of current when powered from the 5V pin or USB connector.

Looks like, yes, still, can’t fathom how that chip managed to consume 4mA. Yet here we are, Thanks for idea!

According to the datasheet, the current consumption of the charge controller BQ25100 is 0.75mA.
There may be other causes for the 4 mA.

edit
When the battery is not connected, the charging terminal falls below 4.2V, so the BQ25100 attempts to charge the battery until it reaches 4.2V. The operating current at this time would be about 4 mA.

1 Like

Heyy guys
facing an issue observe 5 spikes every 100ms from 2uA to 23uA unable to understand whats the issue
i tried multiple ways , those didnt worked i cimmented them
here is following snipet
//----------------------------------------------------------------------------------------------

// BSP : Seeed nRF52 Borads 1.1.1

// Board : Seeed nRF52 Boards / Seeed XIAO nRF52840 Sense

// important : need for Serial.print() <Arduino.h> <Adafruit_TinyUSB.h>

// \Arduino15\packages\Seeeduino\hardware\nrf52\1.1.1\libraries\Bluefruit52Lib\src

//----------------------------------------------------------------------------------------------

// 2023/07/07

// Central sketch : nRF52_XIAO_LightSleepAdvScan_central.ino

// Need to be deleted /Documents/Arduino/libraries/SdFat

#include <nrf_rtc.h>

#include <Arduino.h>

//#include <Adafruit_TinyUSB.h> // For Serial.print()

#include <bluefruit.h> // \Arduino15\packages\Seeeduino\hardware\nrf52\1.1.1\libraries\Bluefruit52Lib\src

#include <Adafruit_SPIFlash.h> // Need to be deleted /Documents/Arduino/libraries/SdFat

#define SLEEP_TIME 30 // Sleep time [sec]

//#define SLEEP_TIME 30 // Sleep time [sec]

Adafruit_FlashTransport_QSPI flashTransport;

//uint8_t timeout = 5;

void setup() {

// Serial port initialization

//Serial.begin(115200);

//while ((!Serial) && (timeout)){

// delay(1000);

// timeout–;

// Enable DC-DC converter

NRF_POWER->DCDCEN = 1; // Enable DC/DC converter for REG1 stage

// Sleep QSPI flash

flashTransport.begin();

flashTransport.runCommand(0xB9); // enter deep power-down mode

flashTransport.end();

//NRF_UART0->ENABLE = 0; // Disable UART

//NRF_SPI0->ENABLE = 0; // Disable SPI

//NRF_TWI0->ENABLE = 0; // Disable I2C

//Bluefruit.begin();

//Bluefruit.Advertising.start();

//Bluefruit.Advertising.stop();

//Bluefruit.end();

//RTC initialization

initRTC(32768 * SLEEP_TIME); // SLEEP_MTIME [sec]

SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;

// Initialization of Bruefruit class

// Bluefruit.begin();

//Bluefruit.setTxPower(4); // Check bluefruit.h:151 for supported values

//Bluefruit.autoConnLed(false); // turn off LED to save power Sleep Current 4uA

// Bluefruit.setConnLedInterval(50); // Should not be used, Sleep current 300uA

suspendLoop();

// Serial.println(“End of initialization”);

}

//*************************************************************************************************************

void loop() {

// Bluefruit.Advertising.stop();

//delay(5000);

//digitalWrite(LED_BLUE, LOW); // turn the LED on (HIGH is the voltage level)

//delay(5000); //Led on // light for 5 seconds, but the rtc in the background keeps running. → light off only for 25 seconds

//digitalWrite(LED_BLUE, HIGH);

//enterLowPowerState();

// delay(SLEEP_TIME * 1000);

// Sleep

__WFI();

__SEV();

__WFI();

// System ON Sleep by FreeRTOS

}

//**************************************************************************************************************

// RTC initialization

void initRTC(unsigned long count30)

{

// See “6.22 RTC - Real-time counter 6.22.10 Registers”

NRF_CLOCK->TASKS_LFCLKSTOP = 1;

NRF_CLOCK->LFCLKSRC = 1; // select LFXO

NRF_CLOCK->TASKS_LFCLKSTART = 1;

while(NRF_CLOCK->LFCLKSTAT != 0x10001)

NRF_RTC2->TASKS_STOP = 1; // stop counter

NRF_RTC2->TASKS_CLEAR = 1; // clear counter

NRF_RTC2->PRESCALER = 0; // set counter prescaler, fout=32768/(1+PRESCALER) 32768Hz

NRF_RTC2->CC[0] = count30; // set value for TRC compare register 0

NRF_RTC2->INTENSET = 0x10000; // enable interrupt CC[0] compare match event

NRF_RTC2->EVTENCLR = 0x10000; // clear counter when CC[0] event

NVIC_SetPriority(RTC2_IRQn,3); // Higher priority than SoftDeviceAPI

NVIC_EnableIRQ(RTC2_IRQn); // enable interrupt

NRF_RTC2->TASKS_START = 1; // start Timer

}

//**************************************************************************************************************

// RTC interrupt handler

extern “C” void RTC2_IRQHandler(void)

{

if ((NRF_RTC2->EVENTS_COMPARE[0] != 0) && ((NRF_RTC2->INTENSET & 0x10000) != 0)) {

NRF_RTC2->EVENTS_COMPARE[0] = 0;  // clear compare register 0 event

NRF_RTC2->TASKS_CLEAR = 1;        // clear counter

//intFlag = true;  

//digitalWrite(LED_RED, LOW);

//delayMicroseconds(10000);      // for LED

//digitalWrite(LED_RED, HIGH);  

}

}
following is ouput observed on PPK


@PJ_Glasso @iggzzzz @daCoder @hobbya @1melc @msfujino

I think the DC/DC converter may be working.

Please use </> when you post your code.

For example, if you want XIAO to wake up every 30 seconds, you should write delay(30000); instead of using RTC, which will reduce the sleep current.

1 Like