I got SAMD21 MINI BREAKOUT I want to use sleep mode on.
I got an GPS connected to Serial1.
Also got GPS enable connected to pin 13(LED_BUILTIN).
I want the unit to read 100 strings from the GPS then go to sleep until an interrupt on pin 12 is detected.
I got it to sleep but not awaik again. It stops on turning pin 13(LED_BUILTIN) high and stops there.
Here is my code. Does anyone know how to fix it?
#include "ArduinoLowPower.h"
// Pin used to trigger a wakeup
const int pin12 = 12;
bool awaikstate = true;
int counter = 0;
void setup() {
  SerialUSB.begin(115200);
  Serial1.begin(9600);
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, HIGH);
  // Set pin 12 as INPUT_PULLUP to avoid spurious wakeup
  pinMode(pin12, INPUT_PULLUP);
  // Attach a wakeup interrupt on pin 12, calling repetitionsIncrease when the device is woken up
  LowPower.attachInterruptWakeup(pin12, awaik, CHANGE);
}
void loop() {
  if (awaikstate) {
    while(Serial1.available() > 0 ){
      String str = Serial1.readStringUntil('\n');
      SerialUSB.println(str);
      counter ++;
    }
  }
  if (counter == 100) {
    counter = 0;
    awaikstate = false;
    digitalWrite(LED_BUILTIN, LOW);
    delay(1000);
    SerialUSB.end();
    Serial1.end();
    delay(200);
    LowPower.sleep();
  }
}
void awaik() {
  if (!awaikstate) {
    digitalWrite(LED_BUILTIN, HIGH);
    delay(200);
    SerialUSB.begin(115200);
    Serial1.begin(9600);
    digitalWrite(LED_BUILTIN, LOW);
    delay(1000);
    awaikstate = true;
  }
}