Page 1 of 1

Switching the Pi 5v using the 3.3v GPIO

Posted: Tue Jun 26, 2018 11:53 am
by AussieDaveF
I want to use the Pi to turn on some strip LEDs at sunset and off at sunrise. I have the code to work the GPIO (pin 12) and the code works on a small 3v LED.

Ultimately I want to use the code to switch a 240v solid state relay, but the 3.3v GPIO doesn't carry enough grunt to make the relay switch. I assume the 5v pin would and therefore would like to create a simple circuit that allows me to use the 5v pin on the Pi to power the relay, and use the programmable 3.3v GPIO pin to control the flow of the 5v through to the relay.

The isolation of an optocoupler appeals to me. Is there one that would do the job without additional transistors and resisters? I've not touched electronics in over 2 decades, so please aim any answers at the dummy/novice level please.

Thanks

Re: Switching the Pi 5v using the 3.3v GPIO

Posted: Tue Jun 26, 2018 2:19 pm
by The Traveler
I'd start with researching: solid state bistable relay. Something like this: https://www.sparkfun.com/products/13015 Note that you can use relays like the one I linked at 3.3vdc inputs, no need for 5vdc.

The rest is writing the control code.

Cheers.

Re: Switching the Pi 5v using the 3.3v GPIO

Posted: Tue Jun 26, 2018 2:54 pm
by pcmanbob
Hi.

I assume you intend to use something like an SSR-20 DA or SSR-40 DA to switch the mains.

in which case you can use an opto isolator to switch the 5v from the pi using a gpio to control the SSR like this.

Image

you will need to use one resistor to limit the current drawn by the LED from the GPIO pin.

you can of course use any GPIO pin you chose to drive the opto isolator just used this one for convenience in the drawing

Re: Switching the Pi 5v using the 3.3v GPIO

Posted: Tue Jun 26, 2018 4:07 pm
by Z80 Refugee
I don't understand the purpose of using an opto-isolator in that circuit, since its isolation capabilities are not being used. A straightforward transistor buffer circuit is all that is needed.

If you require isolation, the output side of the opto-isolator requires an independent voltage supply - not the RPi 5V.

Beginners Guide to Wiring Things to the GPIO

Re: Switching the Pi 5v using the 3.3v GPIO

Posted: Tue Jun 26, 2018 4:42 pm
by scotty101
Z80 Refugee wrote:
Tue Jun 26, 2018 4:07 pm
I don't understand the purpose of using an opto-isolator in that circuit, since its isolation capabilities are not being used. A straightforward transistor buffer circuit is all that is needed.
Agreed, especially since the SSR itself probably contains its own optical isolation.

Re: Switching the Pi 5v using the 3.3v GPIO

Posted: Tue Jun 26, 2018 5:14 pm
by pcmanbob
The only reason I posted was to provided an example of how to do it using an opto isolator as it had been mentioned, and yes there is no isolation because it uses the5V from the pi.

You could just as easily do it using a 2N2222 transistor and a 470 ohm resistor in place of the opto isolator.

Re: Switching the Pi 5v using the 3.3v GPIO

Posted: Tue Jun 26, 2018 5:23 pm
by klricks
I have used a similar SSR by Opto22 and the RPi has no problem with operating the relay via direct GPIO connection.