northstory
Posts: 21
Joined: Mon Feb 25, 2013 7:53 pm
Location: United States, Utah

Re: Question about using the RPi with a relay.

Thu Feb 28, 2013 12:17 am

joan wrote: That aside.

I just had a look at the schematics.

If I had this device I would have connected it up as the OP indicated in the first post with one change.

On the jumper VCC/JD-VCC I'd connect 5V to JD-VCC rather than VCC.

I'd listen for the relays clicking before connecting to A/C though (and being timid I'd stand well back).
I did just that.

And.... it works like a charm. I can even get all four relays to flip on at the same time. I already ordered a ULN2003, so I guess I'll still put it in when it comes just to ease my mind and give my pi even more protection, but I just thought I'd let everyone know that it's working and it was enough to power all 4 relays without it or a 74HC14. Thanks for all the input and help everyone, I really appreciate it!

User avatar
joan
Posts: 15122
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Question about using the RPi with a relay.

Thu Feb 28, 2013 8:34 am

northstory wrote: ...
I did just that.

And.... it works like a charm. I can even get all four relays to flip on at the same time. I already ordered a ULN2003, so I guess I'll still put it in when it comes just to ease my mind and give my pi even more protection, but I just thought I'd let everyone know that it's working and it was enough to power all 4 relays without it or a 74HC14. Thanks for all the input and help everyone, I really appreciate it!
It's always best to experiment with someone else's kit. :D

northstory
Posts: 21
Joined: Mon Feb 25, 2013 7:53 pm
Location: United States, Utah

Re: Question about using the RPi with a relay.

Thu Feb 28, 2013 3:16 pm

joan wrote:
northstory wrote: ...
I did just that.

And.... it works like a charm. I can even get all four relays to flip on at the same time. I already ordered a ULN2003, so I guess I'll still put it in when it comes just to ease my mind and give my pi even more protection, but I just thought I'd let everyone know that it's working and it was enough to power all 4 relays without it or a 74HC14. Thanks for all the input and help everyone, I really appreciate it!
It's always best to experiment with someone else's kit. :D
Haha, yes, luckily I haven't fried it yet.

MorePiPlease
Posts: 21
Joined: Mon Nov 05, 2012 1:59 pm

Re: Question about using the RPi with a relay.

Tue Mar 05, 2013 1:39 am

northstory wrote:
joan wrote: That aside.

I just had a look at the schematics.

If I had this device I would have connected it up as the OP indicated in the first post with one change.

On the jumper VCC/JD-VCC I'd connect 5V to JD-VCC rather than VCC.

I'd listen for the relays clicking before connecting to A/C though (and being timid I'd stand well back).
I did just that.

And.... it works like a charm. I can even get all four relays to flip on at the same time. I already ordered a ULN2003, so I guess I'll still put it in when it comes just to ease my mind and give my pi even more protection, but I just thought I'd let everyone know that it's working and it was enough to power all 4 relays without it or a 74HC14. Thanks for all the input and help everyone, I really appreciate it!
So this is how you wired it? http://www.raspberrypi.org/phpBB3/viewt ... 84#p296884

With the exception being the 5v is going to JD-vcc instead of the vcc on the jumper...right? I really appreciate you starting this thread Northstory! Thanks for all who contributed.

MorePiPlease
Posts: 21
Joined: Mon Nov 05, 2012 1:59 pm

Re: Question about using the RPi with a relay.

Tue Mar 05, 2013 2:16 am

Ok I edited the original photo from this threads opening post and so here is what I am considering:
http://dl.dropbox.com/u/93105539/RPi_to ... Module.jpg

I have read more than just this thread and I understand the risks...will this work? I actually will only be using one of the relays for my current project.

I understand a separate power supply might be necessary for driving all for at once...but if i want to turn on and off a relay that will just be completing a single circuit to my boiler I'd suspect the above referenced picture would work just fine...has anyone tried that? I think the answer is yes hehe but i am not positive.

TravisJBennett
Posts: 2
Joined: Mon Dec 24, 2012 1:47 am

Re: Question about using the RPi with a relay.

Tue Mar 12, 2013 8:02 am

Awesome thread!
I've already done this with my Raspberry Pi (V2 Board) connected to an Arduino Uno R3 over USB, communicating via PySerial, and it works fine but the serial connection gives the whole setup lots of lag and I'd consider it unreliable. If anyone's interested, they do work well together, and it's a Pi-safe setup, but nevertheless I don't recommend it because of the unnecessarily added complexity.

I need reliability on this setup. So, I'd like to cut out the Arduino middleman and hook this up straight. I'm using an 8-relay Sainsmart board though. Perhaps with this many relays a separate PSU would be appropriate... the PSU would thus need to be 5V and at least 500ma or so. I only plan to use up to five at a time though, probably less, as 1-4 on my setup are just for momentary contacting (~25ms via the Arduino works well now).

I'd too like a confirmation on the suggested setup as shown in http://img7.imageshack.us/img7/5451/rpiuln2003relay.jpg -- any takers?
Also, since it appears the chips shown in the picture can handle up to 7 relays, any suggestions on some options for 8-relay or even 16-relay Sainsmart boards?
---
(I'm an engineer and can program well, but I often wish I were a EE. Unfortunately for this project, I'm used to the neutral variety of subatomic particles instead.)

Schorschi
Posts: 245
Joined: Thu Nov 22, 2012 9:38 pm

Re: Question about using the RPi with a relay.

Wed Mar 13, 2013 3:55 am

Just a thought, when you setup the ULN2003 or such... I actually decided to use a ULN2803(a)... it has more darlington pair, so I can drive up to 8 channels versus 7.

TravisJBennett
Posts: 2
Joined: Mon Dec 24, 2012 1:47 am

Re: Question about using the RPi with a relay.

Sun Mar 17, 2013 12:57 am

Thanks! That helps.

On the eight-relay board...
(schematic at http://www.thesunrain.com/Amazon/8%20re ... Module.zip)
... there are two ground pins. One's on the 10-pin header to the far left as usual, and the other is on the now three-pin header (alongside VCC and JD-VCC).

1. With an external +5v power supply, does it matter which ground I connect the power supply's ground to?

EDIT: I figured out I needed to connect It to the Three-Pin Header's GND connection.
2. Other than to the ULN2003A, etc., do I need to connect any additional ground pins on the RasPi straight to the ground pins on the 8-relay board?
EDIT: NO! The voltage drop on any # pin on the large (10-pin) header on the Relay Board will actuate the relay. The GND pin on the large header is one way of achieving this. The use of the ULN2003A or other Solid State Relay to lower the voltage is another. So, the GND pin on the 10-pin header can remain disconnected.

I've tested it out, it works amazingly. I only ever need maybe three relays at a time, but it works great. Thanks everyone!

jkchr1s
Posts: 1
Joined: Mon May 27, 2013 7:46 pm

Re: Question about using the RPi with a relay.

Mon Jun 03, 2013 12:17 am

TravisJBennett wrote: I'd too like a confirmation on the suggested setup as shown in http://img7.imageshack.us/img7/5451/rpiuln2003relay.jpg -- any takers?
Also, since it appears the chips shown in the picture can handle up to 7 relays, any suggestions on some options for 8-relay or even 16-relay Sainsmart boards?
I just finished wiring with this exact setup and it works flawlessly. I did notice that GPIO pin 14 defaults on ON rather than OFF, but as soon as I use wiringPi:

Code: Select all

/usr/local/bin/gpio export 14 out
It turns itself off. Other than that, it's working flawlessly.

pjc123
Posts: 921
Joined: Thu Mar 29, 2012 3:37 pm
Contact: Website

Re: Question about using the RPi with a relay.

Mon Jun 03, 2013 10:37 am

jkchr1s wrote: I just finished wiring with this exact setup and it works flawlessly. I did notice that GPIO pin 14 defaults on ON rather than OFF, but as soon as I use wiringPi:

Code: Select all

/usr/local/bin/gpio export 14 out
See the following charts; as you can see, GPIO14 is HIGH at boot on both the Rev1 and Rev2 boards. For my 8 channel relay card I picked GPIO pins that are listed as MODE=IN and VALUE=LOW, so I boot in a consistent state (One change to the REV 1 chart is that I am also seeing a HIGH on GPIO8 at boot). One caveat to insure it is LOW at boot is to put 10K resistors from each of these GPIO pins to ground because they are floating at boot and can accidentally trip active attached external circuitry before INPUT/OUTPUT and HIGH/LOW states are set in software.

http://www.raspberrypi.org/phpBB3/viewt ... 44&t=35321
My Raspberry Pi Project Page:

https://www.flaminghellmet.com/launch/

jtb
Posts: 17
Joined: Sat Apr 27, 2013 2:07 pm

Re: Question about using the RPi with a relay.

Mon Jun 03, 2013 5:10 pm

Just throw me out if I get obscene but that's the way that I've
always been
I think I know for certain

johal
Posts: 3
Joined: Wed Feb 13, 2013 2:28 pm

Re: Question about using the RPi with a relay.

Mon Jun 17, 2013 7:15 pm

Hi i couldn't find ULN2003 so i am going with NTE2018 which is similar to ULN2003 but with one extra output.

Any suggestions/recommendations? As i have no knowledge about electronics but couldn't find ULN2003 so found similar IC and tried to circuit in similar way.

Image

http://i40.tinypic.com/xknc53.png

Ostrichsak
Posts: 25
Joined: Thu Aug 22, 2013 1:21 pm

Re: Question about using the RPi with a relay.

Fri Oct 11, 2013 2:56 am

Bumping this thread because it's the same question I have. I have the same relay but plan to connect two of them to garage door openers which draw either 3v or 5v (I forget which one at the moment) so power draw will be low and at no point will I ever trigger more than one for a very brief period.. not sustained triggering in any way. Will this wiring be what I want?

SiriusHardware
Posts: 510
Joined: Thu Aug 02, 2012 9:09 pm
Location: UK

Re: Question about using the RPi with a relay.

Tue Oct 15, 2013 7:15 pm

Jim Manley wrote:You also need to be careful about back-EMF pulses onto the Pi's 5 volt power bus (EMF is electro-motive force - what spins motors, activates solenoids and relays, etc.). Whenever a relay coil is deenergized, the magnetic field established in the coil collapses, inducing a potentially damaging current and/or voltage onto the supply pin and other connected devices. The GPIO pins are not protected from such surges (or anything else, for that matter) and one needs to be careful to provide buffering (as do products such as the GertBoard input-output expansion board).
Looking at the pictures, this board clearly has back-emf suppression diodes (D1 to D4) already fitted across each of the relay coils, so that's one less thing to worry about in this particular case.

boyoh
Posts: 1532
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

Re: Question about using the RPi with a relay.

Mon Dec 02, 2013 11:11 pm

northstory wrote:Ah ok, that makes more sense, thank you! However, say I would only ever need to activate one relay at a time, does my logic work in that case? (minus the fact that I drew the line to the VCC instead of the JD-VCC).
Intraducing a diversity factor that not using all your
Relays, are being used at the same ,is only brushing
The problem under the carpet, This is not a good way
Of solving the problem, It limits the use of your relay board

BoyOh
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

jsobota
Posts: 42
Joined: Tue Jul 10, 2012 3:24 pm
Location: Plzen, Czech Republic

Re: Question about using the RPi with a relay.

Thu Feb 06, 2014 4:53 pm

I just want to let you know that I have the very same 4-channel relay board, JD-VCC nad VCC jumpered together, powered directly from the 5V pin from my RPi and I am able to switch on all the relays at once. I already switched the relays on and off thousand times and nothing bad happened. The current delivered from the 5V pin is 283mA when all relays are on and everything works smoothly. I am using a 1.2A PSU.

garycooke
Posts: 79
Joined: Wed Feb 12, 2014 10:38 am

Re: Question about using the RPi with a relay.

Sun Mar 23, 2014 6:18 pm

pksato wrote:5V from RPI GPIO header. Pin 2 or 4.
Current from this 5V is limited by F3 polyfuse.
You can't draw more that around 100mA from these pins.
Relay SRD-05VDC-SLC coil draw 71.4mA.

To power relay board, need 285.6mA. (with all relay activated)

garycooke
Posts: 79
Joined: Wed Feb 12, 2014 10:38 am

Re: Question about using the RPi with a relay.

Sun Mar 23, 2014 6:19 pm

This has been so usefull thank you

NCHippy
Posts: 1
Joined: Fri Jul 18, 2014 10:27 pm

Re: Question about using the RPi with a relay.

Fri Jul 18, 2014 10:36 pm

Thanks for posting this question. This was the help I needed.

I ended up using a ULN2803 darlington driver chip in my application but the instructions from this image worked great with my SainSmart 4ch relay board.

Image Link .... http://img7.imageshack.us/img7/5451/rpiuln2003relay.jpg

Thank you again!

User avatar
dentex
Posts: 180
Joined: Sun May 20, 2012 7:58 am
Location: Italy
Contact: Website

Re: Question about using the RPi with a relay.

Sun Aug 10, 2014 2:53 pm

Thanks for the wonderful thread; there's a lot to learn.
joan wrote:...
If I had this device I would have connected it up as the OP indicated in the first post with one change.

On the jumper VCC/JD-VCC I'd connect 5V to JD-VCC rather than VCC.

I'd listen for the relays clicking before connecting to A/C though (and being timid I'd stand well back).
I just wanted to say that, in regards to the above wiring setup, I found a really nice explanation and tutorial that I thought to share, in THIS YouTube video. I know, a video should not be raised as primary source information about sensitive stuff like those (as the author says at the end), but I think this could be an exception, considering the quality of the material.
One of my projects with the Raspberry Pi:
--------------------------------------------------------
(Raspberry) Pi Aquarium Controller: https://github.com/dentex/piac

gordon77
Posts: 5283
Joined: Sun Aug 05, 2012 3:12 pm

Re: Question about using the RPi with a relay.

Sun Aug 10, 2014 3:58 pm

I modified the same 4-relay board to run from my Pi to avoid needing extra parts to invert the Pi outputs.

gordon77

http://www.raspberrypi.org/forums/viewt ... 54#p470954

User avatar
dentex
Posts: 180
Joined: Sun May 20, 2012 7:58 am
Location: Italy
Contact: Website

Re: Question about using the RPi with a relay.

Sun Aug 10, 2014 4:20 pm

Neat.
I'm really a noob in electronics, so I will not try this out, for the moment ;)
(and sorry, but your images have a tiny dimensions -- would love some bigger pictures for future reference).
But thanks for posting.
One of my projects with the Raspberry Pi:
--------------------------------------------------------
(Raspberry) Pi Aquarium Controller: https://github.com/dentex/piac

gordon77
Posts: 5283
Joined: Sun Aug 05, 2012 3:12 pm

Re: Question about using the RPi with a relay.

Sun Aug 10, 2014 4:24 pm

They are approx 600 / 640 x 480 which should be big enough.

If using windows just right click on them and 'save as' to your PC.

If still not big enough let me know

gordon77

User avatar
dentex
Posts: 180
Joined: Sun May 20, 2012 7:58 am
Location: Italy
Contact: Website

Re: Question about using the RPi with a relay.

Sun Aug 10, 2014 4:34 pm

Well, evidently I'm also a noob on how this forum works... I expected the little hand overlay for the mouse pointer; instead, the downloaded pictures are big enough. Thanks.
One of my projects with the Raspberry Pi:
--------------------------------------------------------
(Raspberry) Pi Aquarium Controller: https://github.com/dentex/piac

Return to “General discussion”