How to turn off XIAO nRF52840 by software?

How to turn off by software? while the battery level is under 2.0V (with LDO)

Hi there,
AFAIK , Doesn’t exist or isn’t supported by Xiao?
I’m doing this in some code, maybe one of the other folks can comment?

void goToPowerOff() {
  setLedRGB(false, false, false);
  Serial.println("Going to System OFF");
  u8x8.clearDisplay();
  u8x8.setCursor(0, 3);
  u8x8.print("SLEEP");
  setupDoubleTapInterrupt(); // not needed here, if already applied..
  delay(1000); // delay seems important to apply settings, before going to System OFF
  //Ensure interrupt pin from IMU is set to wake up device
  nrf_gpio_cfg_sense_input(digitalPinToInterrupt(int2Pin), NRF_GPIO_PIN_PULLDOWN, NRF_GPIO_PIN_SENSE_HIGH);
  delay(2000); // Required delay
  // Trigger System OFF
  NRF_POWER->SYSTEMOFF = 1;
}

HTH
GL :slight_smile:

It looks just power saving sleep. Doesn’t it comsum the battery anyway?
I need real power off. Can it be possible?

To turn off a device by software when the battery level is under 2.0V using a Low Dropout Regulator (LDO), you’ll need to implement a voltage monitoring mechanism. Continuously measure the battery voltage using an analog-to-digital converter (ADC). Ensure the ADC is connected to the battery voltage through appropriate voltage dividers if needed. Within your software, periodically read the ADC values to monitor the battery voltage. When the read voltage drops below 2.0V, trigger a software-controlled shutdown sequence. This sequence should initiate a controlled power-down process, saving any critical data or settings and gracefully shutting down the device’s operations. After the shutdown sequence, you can use the LDO to completely cut off power, ensuring the device is fully turned off, conserving the battery and preventing damage due to undervoltage.