ebaauw / homebridge-rpi

Homebridge plugin for Raspberry Pi.
Apache License 2.0
311 stars 19 forks source link

Making desktop power switch #174

Closed AppStudioLB closed 9 months ago

AppStudioLB commented 9 months ago

Hi, I’m creating a desktop power switch with Homebridge-RPI. I’ve connected a cable from the desktop main board to the Raspberry Pi GPIO for controlling PC power. However, when I use the switch option turned on in HomeKit, the PC starts but shuts down after 3 seconds. I believe the issue is with the duration of power provided. How can I create a toggle(tick) switch in this case? Thank you.

ebaauw commented 9 months ago

See the Wiki.

AppStudioLB commented 9 months ago

I found that if I want to turn on or turn off computer and then I need relay module or extra circuit, not just with gpio pin.

ebaauw commented 9 months ago

The GPIO pins are 3.3V. If the computer uses a different voltage for signalling, you would indeed need a relay.

uli-rpi commented 9 months ago

maybe use a levelshifter 74HTC125 to rise the 3.3V raspi output to 5V.

AppStudioLB commented 9 months ago

There’s 2 cable from motherboard, + and -. When I make them connect, it gives signal to computer. But not too long, because the computer will turn off forcely. At my experiment, rpi gpio could not do this role(make +, - connect).

carmineromano commented 9 months ago

You need a relay to close contacts of pc mainboard power on, in homebridge-rpi plugin you can add a device "lock" so you can set the pulse duration for example 1000ms and you get the turn on. It is a good choice to use a relay to keep the PC ground reference separate and avoid ground loops that could damage the PC or RPI.

AppStudioLB commented 9 months ago

Thank you, everyone, for the advice. I found a great tutorial video on this topic (https://youtu.be/4o3cGVgE2gI?si=nJJiAWaC1o9vGif6). This method made it possible for me to create a computer power switch without buying a relay or other circuits, and it worked wonderfully!