# result.wakeupPin() doesn't return a value

**URL:** https://community.particle.io/t/result-wakeuppin-doesnt-return-a-value/62803
**Category:** Firmware
**Tags:** boron
**Created:** [June 25, 2022, 7:38pm UTC](https://community.particle.io/t/result-wakeuppin-doesnt-return-a-value/62803 "2022-06-25T19:38:14Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![tunahammer](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/tunahammer/32/530_2.png) [@tunahammer](https://community.particle.io/u/tunahammer)
#### Post date: [June 25, 2022, 7:38pm UTC](https://community.particle.io/t/result-wakeuppin-doesnt-return-a-value/62803/1 "2022-06-25T19:38:14Z")

</div>

I’m trying to determine which pin is the reason for my device waking up, but the below code doesn’t work.  
only the 'whichpin" prints in the Log and no int  
The if/else block doesn’t trigger at all either.

I’m following the example here: [Sleep 2.0 Question: SystemSleepResult or SleepResult - #6 by rickkas7](https://community.particle.io/t/sleep-2-0-question-systemsleepresult-or-sleepresult/55676/6)

```auto
#include "Arduino.h"
#undef min
#undef max
#include "Particle.h"

SYSTEM_MODE(MANUAL);  
const pin_t MY_LED = D7;
const pin_t REED_PIN = D6;
SystemSleepConfiguration config;
SerialLogHandler logHandler(LOG_LEVEL_INFO);
void dmy()
{

  digitalWrite(MY_LED, HIGH);
}

void setup() {

  pinMode(MY_LED, OUTPUT);
  pinMode(REED_PIN, INPUT_PULLUP);
  attachInterrupt(REED_PIN, dmy, FALLING);
  Serial.begin(57600);
}

void loop() {
  static uint32_t ms = 0;
  Serial.printlnf("Loop started");
  delay(1000);

  config.mode(SystemSleepMode::STOP)
                    .duration(1min)
                    .flag(SystemSleepFlag::WAIT_CLOUD)
                    .gpio(WKP, FALLING)
                    .gpio(REED_PIN, FALLING)
                    .network(NETWORK_INTERFACE_CELLULAR, SystemSleepNetworkFlag::INACTIVE_STANDBY);
  if (millis() - ms > 5000) {
    digitalWrite(MY_LED, LOW);
    Serial.printlnf("Sleeping");
    System.sleep(config);
    ms = millis();
  }
  Serial.printlnf("I'm awake");
  SystemSleepResult result = System.sleep(config);
  if (result.wakeupReason() == SystemSleepWakeupReason::BY_GPIO) {

    pin_t whichPin = result.wakeupPin();
    Log.info("whichpin", whichPin);
    if(whichPin == D6){
      Log.info("D6 Wakeup received");
    }else if(whichPin == D8){
      Log.info("D8 Wakeup received");
    }
    delay(1000);
  }
}

```

---

<div class="post-metadata">

### Author: ![rickkas7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/rickkas7/32/8681_2.png) [@rickkas7](https://community.particle.io/u/rickkas7)
#### Post date: [June 25, 2022, 7:51pm UTC](https://community.particle.io/t/result-wakeuppin-doesnt-return-a-value/62803/2 "2022-06-25T19:51:49Z")

</div>

That’s not how Log.info works, it’s sprintf-style formatting:

Will not work:

```auto
Log.info("whichpin", whichPin);

```

Use this instead:

```auto
Log.info("whichpin %d", (int)whichPin);

```

---

<div class="post-metadata">

### Author: ![tunahammer](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/tunahammer/32/530_2.png) [@tunahammer](https://community.particle.io/u/tunahammer)
#### Post date: [June 25, 2022, 8:23pm UTC](https://community.particle.io/t/result-wakeuppin-doesnt-return-a-value/62803/3 "2022-06-25T20:23:02Z")

</div>

Thank you @rickkas7 for the super fast response!

I had also messed up by basically calling sleep twice to store the result instead of store the result from the first sleep 🤦‍♂️

---

<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: [July 26, 2022, 6:23am UTC](https://community.particle.io/t/result-wakeuppin-doesnt-return-a-value/62803/4 "2022-07-26T06:23:54Z")

</div>

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