# Off switch for Phat DAC

**URL:** <https://forums.pimoroni.com/t/off-switch-for-phat-dac/10065>\
**Category:** Support\
**Created:** [March 5, 2019, 10:43pm UTC](https://forums.pimoroni.com/t/off-switch-for-phat-dac/10065 "2019-03-05T22:43:38Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![yellowruby](https://avatars.discourse-cdn.com/v4/letter/y/5f8ce5/32.png) [@yellowruby](https://forums.pimoroni.com/u/yellowruby)\
**Post date:** [March 5, 2019, 10:43pm UTC](https://forums.pimoroni.com/t/off-switch-for-phat-dac/10065/1 "2019-03-05T22:43:39Z")

</div>

I have a Phat Dac fitted on my Raspberry Pi Zero W. I am running Moode Audio player v4.4. All works nicely. My question is whether I can add an on/off switch to this combo? What I’ve read indicates that I can add on/off functionality by using a momentary switch off the GPIO 21 and GND connections, but the Phat Dac occupies all of the GPIO. (I could solder leads onto the GPIO of the Pi Zero on the underside of the GPIO header.) Will any of that affect the Phat DAC?

---

<div class="post-metadata">

**Author:** ![Caperjack1953](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/caperjack1953/32/7923_2.png) [@Caperjack1953](https://forums.pimoroni.com/u/Caperjack1953)\
**Post date:** [March 5, 2019, 11:06pm UTC](https://forums.pimoroni.com/t/off-switch-for-phat-dac/10065/2 "2019-03-05T23:06:41Z")

</div>

Hello, I use the pimoroni OnOff -shim ,i soldered it right to the pi zero’s gpio pins .because i dont need the zero for anything else …

> **[OnOff SHIM – Pimoroni](https://shop.pimoroni.com/products/onoff-shim)**
>
> Add a tiny yet convenient power switch to your Pi with OnOff SHIM!

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [March 6, 2019, 10:23am UTC](https://forums.pimoroni.com/t/off-switch-for-phat-dac/10065/3 "2019-03-06T10:23:25Z")

</div>

Another option is to put a Proto Zero with a stacking header on it between your Pi a pHat will get you access to all the GPIO pins. Then wire you shutdown button to that.

> **[ProtoZero – Pimoroni](https://shop.pimoroni.com/products/protozero)**
>
> The ProtoZero is a prototyping board for the Raspberry Pi Zero, that also fits the A+, B+ and Pi2.

  

> **[11mm 2x20 pin Female GPIO Header for Raspberry Pi 3/2/B+/A+ – Pimoroni](https://shop.pimoroni.com/products/2x20-pin-gpio-header-for-raspberry-pi-2-b-a?variant=1132812269)**
>
> Connect your project directly to your Pi with these 2x20 pin GPIO headers!

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [March 6, 2019, 10:31am UTC](https://forums.pimoroni.com/t/off-switch-for-phat-dac/10065/4 "2019-03-06T10:31:59Z")

</div>

You can do a shutdown from a GPIO pin via some python code. I do it on several of my Pi’s. You can pretty well use any GPIO pin you want, one thats not already in use. This will not remove the power to your Pi though. And won’t turn it back on again when pressed a second time.  
With a model 3B 3B+ and 3A+ grounding GPIO 3 physical pin 5 will boot up your Pi. And with a config.txt edit it will let you do a shutdown. I don’t think this works on a Pi Zero though, older 2B’s etc. Same deal here though, does not remove the power to your Pi, it just sits idle like it would if you did the shutdown from Raspbian and left it powered up.  
Jacks option will remove the power from the Pi though.

---

<div class="post-metadata">

**Author:** ![yellowruby](https://avatars.discourse-cdn.com/v4/letter/y/5f8ce5/32.png) [@yellowruby](https://forums.pimoroni.com/u/yellowruby)\
**Post date:** [March 6, 2019, 5:05pm UTC](https://forums.pimoroni.com/t/off-switch-for-phat-dac/10065/6 "2019-03-06T17:05:02Z")

</div>

Thank you all for the assistance. It does look like GPIO pin 21 is not used by the Phat Dac, so I might be able to rig up an on/off button with a momentary tactile switch. To be certain, per alpha’s post, I ought first confirm that a Pi Zero will shutdown fully sans Phat Dac, albeit going the GPIO pin 21 route. (I haven’t confirmed that the GND pin is not used by the Phat Dac. I don’t expect that it would matter if it did.)

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [March 6, 2019, 5:17pm UTC](https://forums.pimoroni.com/t/off-switch-for-phat-dac/10065/7 "2019-03-06T17:17:54Z")

</div>

It won’t matter if the ground is used by another device, its a common connection same as the +5V and 3.3V pins.  
BCM 21 is used by the pHat DAC, physical GPIO pin number 40.  
Physical pin 21 isn’t though, which is BCM 9  
Pinout is here,

> **[pHAT DAC at Raspberry Pi GPIO Pinout](https://pinout.xyz/pinout/phat_dac#)**
>
> An I2S digital to analog audio converter

---

<div class="post-metadata">

**Author:** ![yellowruby](https://avatars.discourse-cdn.com/v4/letter/y/5f8ce5/32.png) [@yellowruby](https://forums.pimoroni.com/u/yellowruby)\
**Post date:** [March 6, 2019, 5:46pm UTC](https://forums.pimoroni.com/t/off-switch-for-phat-dac/10065/8 "2019-03-06T17:46:00Z")

</div>

Ack, I missed that! Thank you for linking the pin out. My reference is this posting:

> **[TonyLHansen/raspberry-pi-safe-off-switch](https://github.com/TonyLHansen/raspberry-pi-safe-off-switch)**
>
> A set of scripts that can be used to provide a "safe power off switch" for a Raspberry Pi. - TonyLHansen/raspberry-pi-safe-off-switch

Seems I could use a pin other than physical pin 40 with modifications to the script. I don’t need a reset feature; just want a safe fully powered off button.

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [March 6, 2019, 6:29pm UTC](https://forums.pimoroni.com/t/off-switch-for-phat-dac/10065/9 "2019-03-06T18:29:02Z")

</div>

It can be any pin you want, I used BCM5 physical PIN 29.  
It looks like he picked that pin because it has a ground pin directly opposite it. That makes it easy to plug his cable in. I think thats why the Pi Foundation picked BCM 3 pin 5, pin 6 is a ground.
