# SystemSleepResult result, How to use in setup

**URL:** https://community.particle.io/t/systemsleepresult-result-how-to-use-in-setup/55851
**Category:** Firmware
**Tags:** boron
**Created:** [April 26, 2020, 12:29am UTC](https://community.particle.io/t/systemsleepresult-result-how-to-use-in-setup/55851 "2020-04-26T00:29:14Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![wesner0019](https://avatars.discourse-cdn.com/v4/letter/w/0ea827/32.png) [@wesner0019](https://community.particle.io/u/wesner0019)
#### Post date: [April 26, 2020, 12:29am UTC](https://community.particle.io/t/systemsleepresult-result-how-to-use-in-setup/55851/1 "2020-04-26T00:29:14Z")

</div>

Im using the new Sleep2.0 and am wondering how I can use the SystemSleepResult in the setup function at the start of the firmware.  
see below

---

<div class="post-metadata">

### Author: ![wesner0019](https://avatars.discourse-cdn.com/v4/letter/w/0ea827/32.png) [@wesner0019](https://community.particle.io/u/wesner0019)
#### Post date: [April 26, 2020, 2:48pm UTC](https://community.particle.io/t/systemsleepresult-result-how-to-use-in-setup/55851/2 "2020-04-26T14:48:50Z")

</div>

Using the below code, and when woken up the SystemSleepResult should return GPIO but it only responds to UNKNOWN.

```auto
#include "Particle.h"

SystemSleepConfiguration config;
SystemSleepResult sleepResult;

SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(MANUAL);
void changeRGBColor(uint8_t brightness, uint8_t red, uint8_t green, uint8_t blue, uint16_t blinkCycle) ;

void setup() {
RGB.control(true);

if (sleepResult.wakeupReason() == SystemSleepWakeupReason::BY_GPIO) {
        changeRGBColor(255, 0, 0, 255, 0);
        delay(3000);
        changeRGBColor(255, 255, 255, 0, 0);
    }
}

void loop() {
config.mode(SystemSleepMode::HIBERNATE)
      .gpio(D2, RISING);
sleepResult = System.sleep(config);
}

//Control LED COLOR
void changeRGBColor(uint8_t brightness, uint8_t red, uint8_t green, uint8_t blue, uint16_t blinkCycle) {
    static uint32_t prevBlinkMillis = 0;
    static bool ledOn = true;

    RGB.brightness(brightness);
    if (blinkCycle == 0) {
        RGB.color(red, green, blue);
        return;
    }

    if (millis() - prevBlinkMillis >= blinkCycle) {
        if (ledOn) {
            RGB.color(red, green, blue);
            ledOn = false;
        } else {
            RGB.color(0, 0, 0);
            ledOn = true;
        }
        prevBlinkMillis = millis();
    }
}

```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/particle/original/3X/6/4/64635adccc35238caa19e9b553ec3e98b163d026.png) [@system](https://community.particle.io/u/system)
#### Post date: [October 26, 2020, 2:48am UTC](https://community.particle.io/t/systemsleepresult-result-how-to-use-in-setup/55851/3 "2020-10-26T02:48:59Z")

</div>

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