Hi, All:
I have so far not been able to use the native serial USB port on the Adafruit Feather M0 if deep sleep modes are selected. The ArduinoLowPower library examples fail on the Feather M0, which I believe is because Adafruit and Arduino differ in how "Serial" is identified in the board manager.
Using Arduino IDE 1.8.19.
I've tried quite a number of experiments, without success. The closest I have come is with this simple RTC deep sleep example from the RTCZero library. It works as expected, with the LED blinking every 5 seconds.
/*
Simple RTC Alarm for Adafruit Feather M0 modified from
RTCzero library example at https://github.com/arduino-libraries/RTCZero
By: CaveMoa
Date: 30/12/15
*/
#include <RTCZero.h>
/* Create an rtc object */
RTCZero rtc;
int AlarmTime;
void setup()
{
rtc.begin();
}
void loop()
{
// Simple indication of being awake
digitalWrite(13, HIGH); // turn the LED on
delay(100);
digitalWrite(13, LOW); // turn the LED off
delay(100);
digitalWrite(13, HIGH); // turn the LED on
delay(100);
digitalWrite(13, LOW); // turn the LED off
AlarmTime += 5; // Adds 5 seconds to alarm time
AlarmTime = AlarmTime % 60; // checks for roll over 60 seconds and corrects
rtc.setAlarmSeconds(AlarmTime); // Wakes at next alarm time, i.e. every 5 secs
rtc.enableAlarm(rtc.MATCH_SS); // Match seconds only
rtc.attachInterrupt(alarmMatch); // Attach function to interupt
rtc.standbyMode(); // Sleep until next alarm match
}
void alarmMatch() // Do something when interrupt called
{}
If I enable and use Serial by adding just three lines as follows, "awake" is printed once, but then nothing is ever again emitted by the Serial port (regardless of whether I use the serial monitor or a terminal program).
However, the LEDs continue to blink, and the COM port remains visible in the Windows 10 Device Manager, unless the "reset" button is double-pressed, whereupon the port becomes COM16.
I've posted this on the Adafruit forum and so far, no one seems to know what the problem is. If anyone knows of an example of successfully combining deep sleep with native USB serial on the Adafruit Feather M0, I would love to see it!
/*
Simple RTC Alarm for Adafruit Feather M0 modified from
RTCzero library example at https://github.com/arduino-libraries/RTCZero
By: CaveMoa
Date: 30/12/15
*/
#include <RTCZero.h>
/* Create an rtc object */
RTCZero rtc;
int AlarmTime;
void setup()
{
rtc.begin();
Serial.begin(115200);
while(!Serial);
}
void loop()
{
// Simple indication of being awake
digitalWrite(13, HIGH); // turn the LED on
delay(100);
digitalWrite(13, LOW); // turn the LED off
delay(100);
digitalWrite(13, HIGH); // turn the LED on
delay(100);
digitalWrite(13, LOW); // turn the LED off
Serial.println("awake");
AlarmTime += 5; // Adds 5 seconds to alarm time
AlarmTime = AlarmTime % 60; // checks for roll over 60 seconds and corrects
rtc.setAlarmSeconds(AlarmTime); // Wakes at next alarm time, i.e. every 5 secs
rtc.enableAlarm(rtc.MATCH_SS); // Match seconds only
rtc.attachInterrupt(alarmMatch); // Attach function to interupt
rtc.standbyMode(); // Sleep until next alarm match
}
void alarmMatch() // Do something when interrupt called
{}