SAMD21 Low Power Operation Using External Event

I've tried unsuccessfully to use ArduinoLowPower and Low-Power libraries to wake up from sleeping using a digital input event.

I have tried every combination. I have search the internet (I found other with same problem with no solution).

This is my typical test sketch.

type or pa /* If no external event on Pin schedule run as expected i.e. LEDs will flash than a delay of 4 seconds and then repeat. If external "wakeup during 4 second sleep, a single 4 second LED flash and then start over.
*/

 #include "ArduinoLowPower.h"
 #define SerialUSB Serial
 
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 2;
int count = 0;
int pin = 0;

// the setup routine runs once when you press reset:
void setup() {
  SerialUSB.begin(9600);
  Serial1.begin(38400);                
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);  
  pinMode(pin, INPUT_PULLUP);  
  LowPower.attachInterruptWakeup(digitalPinToInterrupt(pin), no_BlinkLED, CHANGE); //Wakeup if in LowPower.sleep pin external level change 
}

void loop() {
  
blink_LED();

}

void blink_LED() {

  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second

  count = count + 1;
  if (count < 6) {  }       // repeat blink sequence 5 times

  else { 

    SerialUSB.println("Go to sleep");   //Go to sleep for 4 seconds
    LowPower.sleep(4000);
    count = 0;
  }

}

//external pin interrupt routine
void no_BlinkLED() {
    digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
    delay(4000);
    count = 0;
}
 

I have tried a number of other sketches using the Low-Power Libraries and have never been able to use external input to interrupt sleep mode. It appears this may be particular to the SAMD21?

Any help/suggestions much appreciated. Thank you.

You will find it in this link

engmahmoudsaber,

Thank you again for your help.

I should have been more specific the device I'm referring to is a Seeeduino XIAO.

The sketch I posted is almost directly from Arduino Low Power library example. And does not work on the XIAO.

I had also posted my question on the Seeeduino forums and the response I received simply stated it was not possible to implement low power at least not using the Arduino Low Power Library.

If someone else has suggestion as to how to implement Seeeduino XIAO and or Adafruit QT Py low power shutdown and then wake-up using external input I would appreciate.

Thank you.

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