0

Relay with PI
Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Please be positive and constructive with your questions and comments.

Relay with PI

by lbsa_drexel on Mon Sep 13, 2021 2:15 pm

Hello,

I was looking at some relays and found that you have this one available, https://www.adafruit.com/product/3191, but need a relay that can handle more amps. I have found some other relays that would work for me like this one https://www.mouser.com/ProductDetail/Om ... 4IbA%3D%3D but the coil voltage is 5VDC which will not work for a raspberry pi. I have found that you sell this https://www.adafruit.com/product/757 for 5v to 3.3.v, but is there something that works the other way?

Thanks,
Nick

lbsa_drexel
 
Posts: 19
Joined: Thu Oct 05, 2017 10:54 am

Re: Relay with PI

by mikeysklar on Tue Sep 14, 2021 5:05 pm

What do you require in terms of voltage / current?

mikeysklar
 
Posts: 5767
Joined: Mon Aug 01, 2016 8:10 pm

Re: Relay with PI

by lbsa_drexel on Wed Sep 15, 2021 11:41 am

I am using the relay for a 6v 15amp connection. I chose a 20amp relay to be safe

lbsa_drexel
 
Posts: 19
Joined: Thu Oct 05, 2017 10:54 am

Re: Relay with PI

by mikeysklar on Wed Sep 15, 2021 2:40 pm

We sell a level shifters you can use to easily bump up the Pi 3v logic to 5v to trigger the relay coil.

https://www.adafruit.com/product/3877

I normally use transistors for this as larger relays sometimes need a little more current than the controller pins would provide.

https://www.adafruit.com/product/756

Be sure and use a snubber diode to prevent kickback on the coil.

https://www.adafruit.com/product/1641

mikeysklar
 
Posts: 5767
Joined: Mon Aug 01, 2016 8:10 pm

Re: Relay with PI

by lbsa_drexel on Wed Sep 15, 2021 4:30 pm

Interesting. I will look into these options.

Would it be possible to use this as well https://www.adafruit.com/product/4654 ? To take the 3.3v signal and boost it to 5v for the coil?

lbsa_drexel
 
Posts: 19
Joined: Thu Oct 05, 2017 10:54 am

Re: Relay with PI

by mikeysklar on Thu Sep 16, 2021 11:13 am

The MiniBoost 5v falls into the category of powered electronics in that it is trying to deliver a significant amount of current at a higher voltage. Your relay coil typically wants 10mA - 30mA of current so this device would be way too powerful.

mikeysklar
 
Posts: 5767
Joined: Mon Aug 01, 2016 8:10 pm

Re: Relay with PI

by lbsa_drexel on Tue Sep 21, 2021 3:09 pm

You guys are out of the signal diodes will the power ones work in place?

What is the difference?

Thanks,
Nick

lbsa_drexel
 
Posts: 19
Joined: Thu Oct 05, 2017 10:54 am

Re: Relay with PI

by mikeysklar on Tue Sep 21, 2021 6:58 pm

The power diode will likely work. These large diodes usually have a more significant voltage drop 0.7v for the 1N4001 we sell.

mikeysklar
 
Posts: 5767
Joined: Mon Aug 01, 2016 8:10 pm

Re: Relay with PI

by lbsa_drexel on Wed Sep 22, 2021 1:29 pm

Is this correct? I can use the 5v from the pi to switch the relay with a transistor connected to a GPIO pin. Was not sure where to put the diode though.

The larger board connected from the battery to the relay is a 6v 15amp voltage regulator. And the relay that I want to use does not have a common. https://www.mouser.com/datasheet/2/307/ ... 189816.pdf
Attachments
relay wiring.JPG
relay wiring.JPG (166.55 KiB) Viewed 48 times

lbsa_drexel
 
Posts: 19
Joined: Thu Oct 05, 2017 10:54 am

Re: Relay with PI

by mikeysklar on Wed Sep 22, 2021 4:11 pm

Just looking at the Pi <--> Relay + Diode you are close.

Be sure and set this flyback diode across the trigger coil with the line on the diode connected to this positive side.

82E6C7B2-A685-4A00-9632-0D3714C6C828.png
82E6C7B2-A685-4A00-9632-0D3714C6C828.png (22.29 KiB) Viewed 45 times


You can search for more photos of flyback diode to see what I mean, but in summary one end of the diode connects to the 5v negative coil and the other connects to the 5v positive coil. This will prevent kickback to the Pi.

mikeysklar
 
Posts: 5767
Joined: Mon Aug 01, 2016 8:10 pm

Re: Relay with PI

by lbsa_drexel on Thu Sep 23, 2021 9:13 am

Thanks, now I need to try it out.
Attachments
relay wiring 2.JPG
relay wiring 2.JPG (27.16 KiB) Viewed 41 times

lbsa_drexel
 
Posts: 19
Joined: Thu Oct 05, 2017 10:54 am

Re: Relay with PI

by mikeysklar on Thu Sep 23, 2021 5:06 pm

The diode placement looks good!

When you wire it up try one or two things at a time. eg. Pi --> transistor --> relay coil + diode and make sure you hear the relay correctly clicking before adding all the other stuff in.

mikeysklar
 
Posts: 5767
Joined: Mon Aug 01, 2016 8:10 pm

Re: Relay with PI

by lbsa_drexel on Thu Oct 07, 2021 11:58 am

So this does not work the way that I original thought it would. When you apply the 5v to the collector pin and the 3.3v GPIO pin to the base pin you end up with a voltage of 2.8 on the emitter pin. I thought the transistor would act like a switch and result in 5v on the emitter pin. Is this not how you use a transistor ? I am using a 2N3904BU transistor that I had a few of.

lbsa_drexel
 
Posts: 19
Joined: Thu Oct 05, 2017 10:54 am

Re: Relay with PI

by lbsa_drexel on Thu Oct 07, 2021 2:42 pm

Ok so I figured out how I can get it to work. If you always have the +5v connected and use the transistor to switch the ground it works. I have just been testing with a multimeter right now (I don't have the relay yet) but this is how I believe it should work.

Not really sure why switching the 5v did not work. When I had it wired up that way it did not even matter if I had anything connected to the collector, if the base was powered with the 3.3v the emitter was always 2.8v.
Attachments
transistor_switch2.JPG
transistor_switch2.JPG (43.73 KiB) Viewed 20 times

lbsa_drexel
 
Posts: 19
Joined: Thu Oct 05, 2017 10:54 am

Re: Relay with PI

by lbsa_drexel on Thu Oct 07, 2021 3:17 pm

I also found that this works as well. I think it's the better option.
Attachments
transistor_switch1.JPG
transistor_switch1.JPG (39.43 KiB) Viewed 20 times

lbsa_drexel
 
Posts: 19
Joined: Thu Oct 05, 2017 10:54 am

Please be positive and constructive with your questions and comments.