Go Down

Topic: Restore Feather M0 USB Serial after sleep (Read 390 times) previous topic - next topic

doctor-sparks

Hello

This is a recurring discussion topic, but despite reading everything I have found here and elsewhere I cannot find a working solution.

I am using a Feather M0 datalogger board. To save power between readings I want to put the board to deep sleep and wake it on interrupt. My problem is that after waking the board, I cannot restore the (USB) Serial connection to see Serial.print() debugging messages.

Most of the solutions I've seen are from 2015. Is it possible that newer releases have invalidated those solutions? I am using the most recent software - Arduino IDE 1.8.1, Arduino SAMD 1.6.12, Adafruit SAMD 1.0.13.

Here is some annotated code, based on SimpleSleepUSB.ino from the Feather-M0-Adalogger-master library at https://github.com/cavemoa/Feather-M0-Adalogger. I have tried the combinations indicated, and many others based on other online sources, without success. The LEDs do flash to indicate that the board has returned from sleep, but the final Serial.println() never appears.

Code: [Select]

void loop()
{
  Serial.end();                        // some sketches include this
  USBDevice.detach();            // some sketches include this

  delay(500);                         // wait for detachment (?)
 
  rtc.standbyMode();              // .. or similar method of putting to sleep

  // Flash LED to indicate board is now awake - this works
  digitalWrite(13, HIGH);   
  delay(100);             
  digitalWrite(13, LOW);   
  delay(100);
  digitalWrite(13, HIGH);   
  delay(100);             
  digitalWrite(13, LOW);   

  USBDevice.attach();            // if USBDevice.detach used above
  delay(1000);                       // make serial more reliable (?)
 
  Serial.begin(9600);              // included if Serial.end() used above

  while (! Serial);                   // wait until Serial is ready
  Serial.println("Awake");       //  .. I've never seen this
}


Any help gratefully received.


AloyseTech

HUm, USB stack is a bit tricky to deal with. I have the same issue in a different setup, but still haven't found a workaround...
Try  USBDevice.init(); before the attach function maybe.

doctor-sparks

Thanks AloyseTech, but no cigar. No change in outcome.

Go Up