Issue with the implementation of low-power library for arduino zero

I'm using a SAMD21G18A based board - the arduino zero, for a battery-powered wearable project (a type of computer mouse). I put the device into sleep using the sleep function from the arduino low-power library.

I think the board is going to sleep when I call the .deepSleep() function, using serial to print, as you can see in the picture below. Also including the relevant code.

My issue is that a connected LED continues to work even after the device is put to sleep. The way I understood it, sleep should cut power to attached peripherals. Am I doing something wrong?

I looked through the source code from the library, but that was a dead end. Has anyone experienced a similar issue before?

void nomotion_sleep(float x_value) {
  static float asum;
  static byte i = 0;
  static byte numberof_samples = 10;
  static float sleep_threshold = numberof_samples + 5;
  static uint32_t sleep_timer;

  if (timer1(sleep_timer, 10000)) {
    asum += fabs(x_value);
    SerialUSB.println (asum);
    i += 1;
    if (i == numberof_samples - 1) {
      if (asum < sleep_threshold) {
        asum = 0;
        SerialUSB.println ("sleep now");
        //sleep
        LowPower.deepSleep();
      }
      asum = 0;
      i = 0;
    }
  }
}

is it the Uno sized Arduino Zero with the EDBG chip (two USB connectors)?
or is it an Arduino MKR Zero?

Hi juraj, I'm not sure but it does have two ports. I got this one as a present, but think it's the one currently being sold.

You are wrong in this! Set variables to the current state, and turn them off before going to sleep, tern them back to te stored states on wakeup.

@missdrew So sleep mode is not supposed to turn off peripherals such as LEDs? I should manually turn them off before going into sleep?

That is correct.

1 Like

I think you can't put the EDBG chip to sleep and I guess it has higher consumption than the SAMD.

1 Like

@missdrew thank you. doesn't seem it accomplishes a whole lot then.

@Juraj hmm, I can investigate

Appart from going to sleep, saving energy.

1 Like

Sorry I realize I sounded a bit rude there. Thank you for spending the time helping.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.