Xiao ble sense power off

Hi all,
I would like to know the best power saving solution for my specific case.
My xiao is battery powered (100mah li-ion), and stays most of the time (almost 99%) in system off, until intentionally waken up by the user with a tilt movement.
The rest of the time I really don´t care too much about the consumption, I use some sensors and BLE, but the battery is big enough for all them.
What is really important is the power consumption during system off.
My actual power off sequence is:

  • disable gyroscope
  • enable embedded tilt function on int1 (lsm6ds3)
  • set pinMode of int1 as INPUT_PULLDOWN_SENSE
  • call sd_power_system_off()
    SLEEP…
    It works perfectly but the current drained during the system off is still higher than expected.
    I don´t know exactly what sd_power_system_off() does, maybe I have to power off something else manually before calling the function, something like the bluetooth radio, the flash, I don’t know…
    The only needed hardware is the accelerometer, to wake up the xiao.

Did you set the on-chip regulator to DCDC mode?
Did you set the on-board Flash to DeepPowerDown mode?

hi msfujino.
This is exactly what I need to know, what do I have to switch off or on to get the minimum current in system power off?
I didn´t set the flash in power down mode, neither set on the dcdc regulator.
Is it necessary to power off the ble radio too?

Try this first. And let us know what sleep current value you get.

// on board Flush SPI_1 pins
#define CS1      (25)
#define CLK1     (21)   
#define MOSI1    (20)
#define MISO1    (24)

// Flash functions
void sendSPI(byte data) {
  for (int i = 0; i < 8; i++) {
    digitalWrite(MOSI1, data & 0x80);
    data <<= 1;
    digitalWrite(CLK1, HIGH);
    delayMicroseconds(1);
    digitalWrite(CLK1, LOW);
    delayMicroseconds(1);
  }
}

  // Flash Deep Power Down 
  writeEnable();
  digitalWrite(CS1, LOW);
  sendSPI(0xB9);
  digitalWrite(CS1, HIGH); 

  // Enable DC-DC converter
  NRF_POWER->DCDCEN = 1;
1 Like

writeEnable() is not declared, which library should I use?

Copies were missing.

// on board Flush SPI_1 pins
#define CS1      (25)
#define CLK1     (21)   
#define MOSI1    (20)
#define MISO1    (24)

// Flash commands
#define READ_DATA     0x03
#define WRITE_ENABLE  0x06
#define PAGE_PROGRAM  0x02
#define SECTOR_ERASE  0x20

// Flash functions
void sendSPI(byte data) {
  for (int i = 0; i < 8; i++) {
    digitalWrite(MOSI1, data & 0x80);
    data <<= 1;
    digitalWrite(CLK1, HIGH);
    delayMicroseconds(1);
    digitalWrite(CLK1, LOW);
    delayMicroseconds(1);
  }
}

void writeEnable() {
  digitalWrite(CS1, LOW);
  sendSPI(WRITE_ENABLE);
  digitalWrite(CS1, HIGH);
}


  // on board flash
  pinMode(CS1, OUTPUT);
  pinMode(CLK1, OUTPUT);
  pinMode(MOSI1, OUTPUT);
  pinMode(MISO1, INPUT);
  digitalWrite(CS1, HIGH);   // CS1 HIGH

  // Flash Deep Power Down 
  writeEnable();
  digitalWrite(CS1, LOW);
  sendSPI(0xB9);
  digitalWrite(CS1, HIGH); 

  // Enable DC-DC converter
  NRF_POWER->DCDCEN = 1;
  

There is another way.

#include <Adafruit_SPIFlash.h>

  // Shut down unused QSPI flash memory
  Adafruit_FlashTransport_QSPI flashTransport;
  flashTransport.begin();
  flashTransport.runCommand(0xB9);
  flashTransport.end();

  // Enable DC-DC converter
  NRF_POWER->DCDCEN = 1;


Is BoardServicePackage mbedd or non-mbed?

This may possibly be helpful.

non-mbed

so I suppose the second way will work, right?

lucamox,
Yes, I think so.

I ended up using the first solution, because of a library interference between Adafruit_SPIFlash.h and InternalFileSystem.h
Seems to work well, but I have to check the current, I will reply in a few days.

Thks
Luca

1 Like