XIAO BLE Sense in deep sleep mode

Hey, quite a big discussion. I read a lot of it multiple times and still didn’t manage to get the XIAO nrf52840 to sleep and wake on interrupt.
Indeed it seems like everyone is just comparing their sleep current, but no-one ever made it work to wake up the board. At least there is no complete functioning code in this discussion.

@Rhys3logy Asked for the same thing that I’m about, but he never got an answer:

So I’ll give exact information on what I’m doing:
Board: XIAO nRF52840
Boards Manager: Speed nRF52 Board
IDE: Arduino IDE

This is my minimal code to turn the chip off, which doesn’t work:

void setup() {
  pinMode(LED_GREEN, OUTPUT);
  pinMode(LED_RED, OUTPUT);
}

int c;
void loop() {
  c++;
  digitalWrite(LED_GREEN, c % 2 == 0 ? HIGH : LOW);
  delay(1000);
  if (c == 10) {
    digitalWrite(LED_RED, LOW);
    sd_power_system_off();
  }
}

This should put the board to sleep right? Well sd_power_system_off() does exactly nothing. It executes and the program just continues.
I managed to get the board to shut down via the mentioned NRF_POWER->SYSTEMOFF = 1; but I tried everything to wake it up, but the only way to do it seems to be a reset via reset button, or killing the power and plugging it back in.

So this sample is so minimal, and the task ist so basic. Is there anyone who actually got this to work and can post steps to reproduce? The fact that sd_power_system_off() doesn’t do anything on my side makes me suspicious, maybe this could hint something?

I’m new to hardware programming and this is my second project and the first with this chip. What I want to do in the very end (getting the thing to shut down and at least restart upon button press would be the first step) - is to:

  • Go into sleep
  • Wake up every now and again (just like delay() but non-blocking)
  • Check some variables and the time (they must persist)
  • Go back to sleep
  • Additional: Wake Up on button press and run the program normally

Maybe some of the experts here can help, we spent a whole day with 2 experienced programmers and didn’t manage to do that.

Greetings from Germany,
Noblauch

1 Like