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/
Locked
User avatar
lbsa_drexel
 
Posts: 31
Joined: Thu Oct 05, 2017 10:54 am

Relay with PI

Post by lbsa_drexel »

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

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Relay with PI

Post by mikeysklar »

What do you require in terms of voltage / current?

User avatar
lbsa_drexel
 
Posts: 31
Joined: Thu Oct 05, 2017 10:54 am

Re: Relay with PI

Post by lbsa_drexel »

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

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Relay with PI

Post by mikeysklar »

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

User avatar
lbsa_drexel
 
Posts: 31
Joined: Thu Oct 05, 2017 10:54 am

Re: Relay with PI

Post by lbsa_drexel »

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?

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Relay with PI

Post by mikeysklar »

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.

User avatar
lbsa_drexel
 
Posts: 31
Joined: Thu Oct 05, 2017 10:54 am

Re: Relay with PI

Post by lbsa_drexel »

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

What is the difference?

Thanks,
Nick

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Relay with PI

Post by mikeysklar »

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

User avatar
lbsa_drexel
 
Posts: 31
Joined: Thu Oct 05, 2017 10:54 am

Re: Relay with PI

Post by lbsa_drexel »

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 169 times

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Relay with PI

Post by mikeysklar »

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 166 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.

User avatar
lbsa_drexel
 
Posts: 31
Joined: Thu Oct 05, 2017 10:54 am

Re: Relay with PI

Post by lbsa_drexel »

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

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Relay with PI

Post by mikeysklar »

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.

User avatar
lbsa_drexel
 
Posts: 31
Joined: Thu Oct 05, 2017 10:54 am

Re: Relay with PI

Post by lbsa_drexel »

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.

User avatar
lbsa_drexel
 
Posts: 31
Joined: Thu Oct 05, 2017 10:54 am

Re: Relay with PI

Post by lbsa_drexel »

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 141 times

User avatar
lbsa_drexel
 
Posts: 31
Joined: Thu Oct 05, 2017 10:54 am

Re: Relay with PI

Post by lbsa_drexel »

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 141 times

Locked
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/

Return to “Adafruit Raspberry Pi® accessories”