Running Boron under 3.1.0. Issue with Sleep awakening condensed to example below. When A3 GPIO grounded, resets to sleep again with original duration. On second GPIO trigger, it awakens. Also, if no GPIO triggered, the code below comes out of sleep in 1 minute, goes back to sleep for 1 minute, and then comes out awake. Any similar experiences, or tips on how to enable single awakening? Thanks.
long int dur=60000L;
void setup() {
pinMode ( A3, INPUT_PULLUP ) ;
SystemSleepConfiguration config;
config.mode(SystemSleepMode::ULTRA_LOW_POWER)
.gpio(A3, FALLING)
.duration(dur);
System.sleep(config);
SystemSleepResult result = System.sleep(config);
}
void loop() {
} // loop
I’m not entirely sure what you are asking there.
What do you expect to happen?
What exactly does happen?
When you add some check statements (e.g. Serial.print(), digitalWrite(D7, ...), RGB.color() or such) you may get a better understanding of what’s happening internally.
From the code above you’d not be able to distinguish between the first and the second sleep statement and whether loop() ever gets executed or not.
I’d also make sure wake condition for the first sleep statement goes away before you enter your second sleep cycle.
e.g.
System.sleep(config);
while(!digitalRead(A3)) Particle.process; // wait for A3 to be released
SystemSleepResult result = System.sleep(config);
Thanks for that input. Will give that a try in the future. Still, the sleep function executes twice, even after totally removing the GPIO trigger option.
WOW, you indirectly solved my problem!!! I was in the process of removing the GPIO statements for clarity, and also deleted **SystemSleepResult result = System.sleep(config);.This fixed the problem, which I can now remedy in other ways. I’m obviously not tuned in to all the details of the SystemSleepResult class.
For the record, I’m in the process of using the sleep function to reduce current drain in an existing solar powered project. Unexplained timing problems were finally traced to the sleep function. The Boron is USB powered from laptop here in the lab. My monitoring technique is to use a stopwatch to observe the status LED. Works very well in the long run.