Back in June, Erik shared some code to determine the wake up source for the deepSleepAtMost functions. If the source was not the timer, how can I read the time remaining on the timer? I want to spend most of the time in deep sleep, waking to service interrupts, and sending status messages twice a day. These functions get me 90% of the way there.
Thanks
void setup() {
Dash.begin(); //Enable the Dash class
Serial2.begin(115200); //Enable Serial2
pinMode(R04, INPUT_PULLUP); //Set R04 to input with a pull-up
Dash.attachWakeup(R04, FALLING); //Use R04 as a wake-up source (WU14)
//Will generate a wake-up when transitioning
//from high to low. Since R04 is pulled high
//internally, grounding R04 will generate
//the wake-up event
}
static uint32_t count = 1;
void loop() {
Dash.onLED(); //LED is on while awake
Serial2.print("Dash Timed Sleep At Most Demo Run ");
Serial2.println(count);
Serial2.println("Going to sleep for at most 10 seconds.");
Serial2.waitToEmpty(); //before sleeping, clear the Serial output buffer
Serial2.flush(); //clear the Serial input buffer for the next run
Dash.deepSleepAtMostSec(10); //deep sleep 10 seconds, or until R04 goes low
count++; //Awake now
uint32_t source = Dash.lastWakeupSource(); //get the source of the last
//wake-up event
Serial2.print("Last wake-up source(");
Serial2.print(source);
Serial2.print("): ");
Serial2.println(source == 16 ? "Timer" : "R04");
}