# How to wakeup from sleep on more than one input?

**URL:** <https://community.particle.io/t/how-to-wakeup-from-sleep-on-more-than-one-input/20610>\
**Category:** Firmware\
**Created:** [March 1, 2016, 1:18am UTC](https://community.particle.io/t/how-to-wakeup-from-sleep-on-more-than-one-input/20610 "2016-03-01T01:18:52Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcardona](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/jcardona/32/7570_2.png) [@jcardona](https://community.particle.io/u/jcardona)\
**Post date:** [March 1, 2016, 1:18am UTC](https://community.particle.io/t/how-to-wakeup-from-sleep-on-more-than-one-input/20610/1 "2016-03-01T01:18:52Z")

</div>

Hi everyone,

I am using the System.sleep(uint16\_t wakeUpPin, uint16\_t edgeTriggerMode) system call on the photon.  
The code works as documented, but I would need to be able to wake up on either of two input signals, not just one.

I have read somewhere that the STM32 supports this, but Particle’s firmware does not. I was wondering if someone can share some pointers on how to work around this limitation and configure the photon to wake up on two pins instead of one.

Any help will be greatly appreciated!

Cheers,

---

<div class="post-metadata">

**Author:** ![CuriousTech](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/curioustech/32/3315_2.png) [@CuriousTech](https://community.particle.io/u/CuriousTech)\
**Post date:** [March 1, 2016, 1:28am UTC](https://community.particle.io/t/how-to-wakeup-from-sleep-on-more-than-one-input/20610/2 "2016-03-01T01:28:45Z")

</div>

2 diodes as OR logic?

---

<div class="post-metadata">

**Author:** ![jcardona](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/jcardona/32/7570_2.png) [@jcardona](https://community.particle.io/u/jcardona)\
**Post date:** [March 1, 2016, 1:54am UTC](https://community.particle.io/t/how-to-wakeup-from-sleep-on-more-than-one-input/20610/3 "2016-03-01T01:54:08Z")

</div>

Thanks for the suggestion. Yes, that would work. I was trying to avoid a hardware solution… 😄

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [March 1, 2016, 3:07am UTC](https://community.particle.io/t/how-to-wakeup-from-sleep-on-more-than-one-input/20610/4 "2016-03-01T03:07:12Z")

</div>

I have not tried it, but in the docs about [`attachInterrupt()`](https://docs.particle.io/reference/firmware/photon/#attachinterrupt-) you'll find this note

> [@](#):
>
> Photon: All pins with the exception of D0 and A5 (since at present Mode Button external interrupt(EXTI) line is shared with D0, A5). Also please note following are the pins for which EXTI lines are shared so only one can work at a time:  
> D1, A4  
> D2, A0, A3  
> D3, DAC  
> D4, A1

So you could try one of the shared EXTI pins if you provide a suitable external pull-resistor on the pin that you did _not_ state in the sleep call.  
No idea if this works, but an easy try 😉  
If you use D0/A5 you might even be able to use the SETUP button for waking.

* * *

If this doesn't work you could look in the open source repo to see how `sleep()` sets the pin up for waking and copy that.

---

<div class="post-metadata">

**Author:** ![jcardona](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/jcardona/32/7570_2.png) [@jcardona](https://community.particle.io/u/jcardona)\
**Post date:** [March 1, 2016, 4:53am UTC](https://community.particle.io/t/how-to-wakeup-from-sleep-on-more-than-one-input/20610/5 "2016-03-01T04:53:51Z")

</div>

Hi ScruffR,

Nice suggestion. I am currently using D1 and D2. I would have to reroute my button to use A4 to try it. Interesting!

Thanks,

Javier

---

<div class="post-metadata">

**Author:** ![RWB](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/rwb/32/22599_2.png) [@RWB](https://community.particle.io/u/RWB)\
**Post date:** [March 1, 2016, 4:55am UTC](https://community.particle.io/t/how-to-wakeup-from-sleep-on-more-than-one-input/20610/6 "2016-03-01T04:55:10Z")

</div>

I have been wondering about this exact same thing. Can I wake from multiple pins?

Please do post your results about this.

---

<div class="post-metadata">

**Author:** ![mdma](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/mdma/32/1924_2.png) [@mdma](https://community.particle.io/u/mdma)\
**Post date:** [March 2, 2016, 8:45am UTC](https://community.particle.io/t/how-to-wakeup-from-sleep-on-more-than-one-input/20610/7 "2016-03-02T08:45:02Z")

</div>

I’ll discuss this with our firmware engineers internally - it’s something that’s come up once or twice.

I’m fairly sure it’s technically possible - the trickier part is determining how the API will look.

---

<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:** [November 23, 2016, 7:24pm UTC](https://community.particle.io/t/how-to-wakeup-from-sleep-on-more-than-one-input/20610/8 "2016-11-23T19:24:55Z")

</div>

@mdma, just checking to see if anything has been discovered for this?

---

<div class="post-metadata">

**Author:** ![trackdork](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/trackdork/32/12551_2.png) [@trackdork](https://community.particle.io/u/trackdork)\
**Post date:** [December 12, 2016, 1:41am UTC](https://community.particle.io/t/how-to-wakeup-from-sleep-on-more-than-one-input/20610/9 "2016-12-12T01:41:43Z")

</div>

I second this request. In a previous thread someone mentioned registering for interrupts on the pins and using normal sleep, which will wakeup from any interrupt, however I also need deep sleep for my application.

---

<div class="post-metadata">

**Author:** ![Ric](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/ric/32/514_2.png) [@Ric](https://community.particle.io/u/Ric)\
**Post date:** [December 12, 2016, 2:05am UTC](https://community.particle.io/t/how-to-wakeup-from-sleep-on-more-than-one-input/20610/10 "2016-12-12T02:05:22Z")

</div>

You can only wake from deep sleep with a rising edge on the WKP pin, so if you need multiple inputs, you should use an OR gate, or a couple of diodes as suggested by @CuriousTech.

---

<div class="post-metadata">

**Author:** ![trackdork](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/trackdork/32/12551_2.png) [@trackdork](https://community.particle.io/u/trackdork)\
**Post date:** [December 12, 2016, 3:02am UTC](https://community.particle.io/t/how-to-wakeup-from-sleep-on-more-than-one-input/20610/11 "2016-12-12T03:02:52Z")

</div>

Thanks!

---

<div class="post-metadata">

**Author:** ![hwestbrook](https://avatars.discourse-cdn.com/v4/letter/h/5f9b8f/32.png) [@hwestbrook](https://community.particle.io/u/hwestbrook)\
**Post date:** [March 10, 2017, 12:02am UTC](https://community.particle.io/t/how-to-wakeup-from-sleep-on-more-than-one-input/20610/12 "2017-03-10T00:02:45Z")

</div>

Hi @mdma,

Wondering if any progress has been made on this or if you’ve determined if it is possible? Would like to accomplish this without having to use and OR gate or diodes.
