Boron Sleep Twice Enabled

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;
    .gpio(A3, FALLING)
    SystemSleepResult result = System.sleep(config);
void loop() {
}  // loop

A 13k Ω pull-up is being internally added to the sleep pin. Perhaps this is affecting things. Here is a link about it:

Try using an external pullup instead and change to:


to see if that helps.

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.

    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.

Again, thanks for you clarification query.


Yep - you are calling sleep twice, but the second time the result is stored as result.

Also .gpio(A3, FALLING) sets the PinMode etc. for you.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.