deesturbe
Posts: 2
Joined: Sat Jul 24, 2021 1:14 am

Using rpi in place of a physical switch

Sat Jul 24, 2021 1:19 am

Hello, I just got a rpi, with a Poe hat and some accessories, I was wondering if it was possible to use a gpio pin to control the switch.
It is a simple 2 position switch, on/off the only issue is one of the connections is +5v will that hurt the rpi if I connect it, and is there a safe way of doing what I want?
Thanks in advance.

User avatar
neilgl
Posts: 3512
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near The National Museum of Computing

Re: Using rpi in place of a physical switch

Sat Jul 24, 2021 7:00 pm

Yes, 5V will damage the pi GPIO as it runs at 3V3. You will need an interface using a transistor or a mosfet or a relay.

deesturbe
Posts: 2
Joined: Sat Jul 24, 2021 1:14 am

Re: Using rpi in place of a physical switch

Sat Jul 24, 2021 10:25 pm

Is it ok if I attach a bc550 transistor to the circuit (base to the gpio pin, and connecting emmiter side to 5v output from hdmi switch, and collector side to ground on the hdmi switch) and toggling gpio pin value to output and high to controll the "button" that I am using the rpi in place for.
That grounds the 5v output from the emmiter side to ground on the collector side which is how the button in place worked I assume.

pidd
Posts: 2527
Joined: Fri May 29, 2020 8:29 pm
Location: Wirral, UK
Contact: Website

Re: Using rpi in place of a physical switch

Sun Jul 25, 2021 3:01 am

The circuit you describe would need a PNP transistor, the BC550 is NPN, but it still wouldn't work because the GPIO pin wouldn't go above 4.6V to switch the transistor off.

Also you would need a current limiting resistor in the base of the transistor.

We could do with knowing what amount of current flows through the switch.

If isolation is required (if you don't know otherwise, assume it does need isolation) then a relay board is probably the better solution.

Return to “Other projects”