AussieDaveF
Posts: 21
Joined: Tue Jun 26, 2018 11:36 am

Switching the Pi 5v using the 3.3v GPIO

Tue Jun 26, 2018 11:53 am

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

User avatar
The Traveler
Posts: 363
Joined: Sat Oct 21, 2017 3:48 pm

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

Tue Jun 26, 2018 2:19 pm

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.
Retired IT professional, C programmer and "beardie weirdie".
RPi interests: Developing an Infinite Improbability Drive
“Thinking outside of the box allows you to get rewards outside of your reach.” Matshona Dhliwayo

pcmanbob
Posts: 9465
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

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

Tue Jun 26, 2018 2:54 pm

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
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
Z80 Refugee
Posts: 358
Joined: Sun Feb 09, 2014 1:53 pm

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

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.

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
Military and Automotive Electronics Design Engineer (retired)

For the best service: make your thread title properly descriptive, and put all relevant details in the first post (including links - don't make us search)!

scotty101
Posts: 3958
Joined: Fri Jun 08, 2012 6:03 pm

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

Tue Jun 26, 2018 4:42 pm

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.
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

pcmanbob
Posts: 9465
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

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

Tue Jun 26, 2018 5:14 pm

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.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

klricks
Posts: 7154
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

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

Tue Jun 26, 2018 5:23 pm

I have used a similar SSR by Opto22 and the RPi has no problem with operating the relay via direct GPIO connection.
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.

Return to “Other projects”