deathtrap
Posts: 7
Joined: Wed Jan 23, 2013 2:57 am

Safely Interfacing 8 Relay Module via GPIO

Wed Jan 23, 2013 3:19 am

I am looking to get some input on the "correct" and safe way to connect my Pi to a 5v 8 relay module via the GPIO. I have read countless threads regarding the topic and have seen a good amount of users directly connecting the appropriate GPIO pins to the appropriate pins on the module. I have also read several posts about creating a buffer between the Pi and the relay module. I have the same relay module that is used in this video. http://www.youtube.com/watch?v=8X6PgYaegz0. Thanks for the input!!!

User avatar
aTao
Posts: 1095
Joined: Wed Dec 12, 2012 10:41 am
Location: Howlin Eigg

Re: Safely Interfacing 8 Relay Module via GPIO

Wed Jan 23, 2013 4:02 am

It is not easy to give good advice from a you tube video. Anyone designing an electronic circuit needs accurate data on all components.
It looks like the relay modules have input isolation which is probably opto isolators. Which means you might be able to connect directly to your RPi.
If you could provide:
Best: a link to a data sheet for the relay board,
Good: a link to a suppiers web site
OK: a part number
Bad: a clear image of the board
Not much use: YouTube video

Then someone could give a definitive answer.
>)))'><'(((<

deathtrap
Posts: 7
Joined: Wed Jan 23, 2013 2:57 am

Re: Safely Interfacing 8 Relay Module via GPIO

Wed Jan 23, 2013 4:29 am

Thanks for your reply. Here is a link to the eBay auction this provides some technical specs. http://tinyurl.com/a3qd84b

deathtrap
Posts: 7
Joined: Wed Jan 23, 2013 2:57 am

Re: Safely Interfacing 8 Relay Module via GPIO

Wed Jan 23, 2013 4:37 am

Here is a link to the what appears to be the manufacturer description of the module. http://www.sainsmart.com/8-channel-dc-5 ... logic.html

User avatar
abishur
Posts: 4501
Joined: Thu Jul 28, 2011 4:10 am
Location: USA

Re: Safely Interfacing 8 Relay Module via GPIO

Wed Jan 23, 2013 4:53 am

Well it certainly *looks* the same, but aTao said it's hard to give good advice from a youtube video. These relay boards all tend to look the same but can vary widely. My advice would be to look up the part number of the component in "front" of the relays and see if they're opto-isolators or darlington transistors. The eBay listing says each one needs "15-20mA driver current" but is non-specific is that is on the activating the relay side of things (i.e. after the mystery component) or on the activating our mystery component side of things. My *guess* is that they are darlington transistors and can be activated at low current from 3v3 voltage and he has a common 5v going to the other side to drive the relays (5v coming from the 5v pin in the GPIO strip).

I confess I'm slightly irked as this is an idea (running sprinklers and opening/closing garage door with pi via web interface) a long time ago and he beat me to it :lol:

So again, find out exactly what that mystery part is (the eBay listing doesn't say) and build the rest of your circuit to power it safely ;-)
Dear forum: Play nice ;-)

User avatar
aTao
Posts: 1095
Joined: Wed Dec 12, 2012 10:41 am
Location: Howlin Eigg

Re: Safely Interfacing 8 Relay Module via GPIO

Wed Jan 23, 2013 5:08 am

deathtrap wrote:Here is a link to the what appears to be the manufacturer description of the module. http://www.sainsmart.com/8-channel-dc-5 ... logic.html
Good, one of the images is a schematic for one channel. Sadly SainsMart have swamped the critical component with their copyright logo, never mind though.
The module is described as being TTL compatible, it also has 2 LEDs in the input circuit.

On those grounds I would use packaged darlington drivers (or transistors) to buffer the RPis outputs.

http://cpc.farnell.com/jsp/search/produ ... tt=SC08607 has 8 channels on one chip, it has input resistors so you would only need one of these and no more components to drive the relay board
>)))'><'(((<

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

Re: Safely Interfacing 8 Relay Module via GPIO

Wed Jan 23, 2013 12:41 pm

The pictures you are showing are exactly the same as the Sainsmart 8 channel relay board that I am using (Same markings on both the board and components). It will not run on 3.3v due to the 1K resistor on the board being too high a value to reliably light up the opto enough to eventually trip the relays (There is a single transistor on the opto output, not a darlington pair). The opto circuit is active low and I have a transistor on each input to make it active high. I am not sure whether you can use it active low, skip the transistor, and sink the 5V through the GPIO ports, so I didn't try want to try it. First, I am not sure you can sink 5V through a GPIO port, and secondly if you accidentally set the GPIO port to active high this would cause 3.3v to meet 5v at the opto.

Here are answers to the various posted questions about the board and how I have it set up and working:

http://www.raspberrypi.org/phpBB3/viewtopic.php?t=19222

I have a copy of the schematic and other information that I found, but I have no way to permanently upload it to this forum without using third party web sites that have timeouts (it is a pdf).
My Raspberry Pi Project Page:

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

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

Re: Safely Interfacing 8 Relay Module via GPIO

Wed Jan 23, 2013 1:33 pm

Also, Abishur may bring up a vaild point. The fact that the one from Ebay states that it requires 15-20ma means it is either a typo, it is a different board than mine with a different input circuit, or Sainsmart modified their circuitry since I bought mine. The reason I say this because each of my optos uses 1.49ma at 5V and each coil uses 50ma at 5V. At 3.3V, the .49ma current flow is not enough to drive the opto on my board (sometimes the relays click, other times they do not).

The markings on my opto are:

B1202
817C
G

The markings on my relay are:

Songle
SRD-05VDC-SL-C

That is not to say that on the one one Ebay they might have reduced the value of the resistor on the opto from 1K in order to get it to operate at the higher 15-20ma current, or changed the relay to operate at a lower current, etc., etc., etc.
My Raspberry Pi Project Page:

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

deathtrap
Posts: 7
Joined: Wed Jan 23, 2013 2:57 am

Re: Safely Interfacing 8 Relay Module via GPIO

Wed Jan 23, 2013 2:32 pm

pjc123 wrote:The pictures you are showing are exactly the same as the Sainsmart 8 channel relay board that I am using (Same markings on both the board and components). It will not run on 3.3v due to the 1K resistor on the board being too high a value to reliably light up the opto enough to eventually trip the relays (There is a single transistor on the opto output, not a darlington pair). The opto circuit is active low and I have a transistor on each input to make it active high. I am not sure whether you can use it active low, skip the transistor, and sink the 5V through the GPIO ports, so I didn't try want to try it. First, I am not sure you can sink 5V through a GPIO port, and secondly if you accidentally set the GPIO port to active high this would cause 3.3v to meet 5v at the opto.

Here are answers to the various posted questions about the board and how I have it set up and working:

http://www.raspberrypi.org/phpBB3/viewtopic.php?t=19222

I have a copy of the schematic and other information that I found, but I have no way to permanently upload it to this forum without using third party web sites that have timeouts (it is a pdf).
Thank you for the information, is there any chance you could email me the schematics ([email protected])? I would really appreciate it. Thanks again!

User avatar
[email protected]
Posts: 2024
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK

Re: Safely Interfacing 8 Relay Module via GPIO

Wed Jan 23, 2013 4:04 pm

deathtrap wrote:I am looking to get some input on the "correct" and safe way to connect my Pi to a 5v 8 relay module via the GPIO. I have read countless threads regarding the topic and have seen a good amount of users directly connecting the appropriate GPIO pins to the appropriate pins on the module. I have also read several posts about creating a buffer between the Pi and the relay module. I have the same relay module that is used in this video. http://www.youtube.com/watch?v=8X6PgYaegz0. Thanks for the input!!!
Well that video looks safe enough to me. What is it that you need more than that? Those boards already have opto isolators and buffers - they have the lot and really can not be beaten for the price I've seen them for on ebay, etc. (I mean really - they're practically giving them away!)

The biggest issue you'll have with those is making sure that the Pi can supply enough current at 5v to reliably trigger all the relays at the same time.

-Gordon
--
Gordons projects: https://projects.drogon.net/

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

Re: Safely Interfacing 8 Relay Module via GPIO

Wed Jan 23, 2013 4:55 pm

deathtrap wrote: Thank you for the information, is there any chance you could email me the schematics ([email protected])? I would really appreciate it. Thanks again!
Yes, I will email the schematic, circuit board drawing and technical specifications for the board to you. I found these floating around different places on the Internet; they are accurate for my Sainsmart board. As I recall some of it came from an Arduino forum. You will have a much better understanding of what is going on with the schematic. Just make sure that the components in the schematic exactly match your circuit board as was mentioned. If you have any other questions feel free to ask.

Update: sent.
My Raspberry Pi Project Page:

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

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

Re: Safely Interfacing 8 Relay Module via GPIO

Wed Jan 23, 2013 5:57 pm

[email protected] wrote: The biggest issue you'll have with those is making sure that the Pi can supply enough current at 5v to reliably trigger all the relays at the same time.

-Gordon
The way I get around that is to use a secondary power supply for the coils. What is nice about the Sainsmart circuit board is that it has a jumper on it that, once removed, allows you to supply voltages to the opto and coil separately. Another way around this would be to use one large power supply (2 amps or so) and split the cable out so one side powers the pi and the other the relay board.

I use the pi's GPIOs to turn each transistor on which turns on each opto. That requires only 1.49ma per opto from the pis 5V rail for a total of 1.49ma x 8 = 11.92ma.

Now the coils draw between 50 to 60ma per coil. 60ma x 8 = 480ma. Now trying to power the pi, a high power wifi dongle, keyboard, etc, from the micro usb port would just be way too much current draw. I also require a headless unit without a powered hub. Therefore I use a secondary 5V supply to power the coils.

Actually, in reality I don't have a second supply per se; I am running on a large 12V battery which I convert to 5V using one of those car cigarette lighter power supplies. It has two outputs, one is rated at 1 amp, the other at 2.5 amps (One goes to the pi and the other powers the coils). I have built and tested everything except the power supply split, which I will get to test after I move everything from my breadboard to a soldered circuit board, mount it all in an aluminum chassis, and wire everything up, which I am doing in between typing on this forum; although I expect no surprises.
My Raspberry Pi Project Page:

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

User avatar
[email protected]
Posts: 2024
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK

Re: Safely Interfacing 8 Relay Module via GPIO

Wed Jan 23, 2013 6:19 pm

pjc123 wrote: I use the pi's GPIOs to turn each transistor on which turns on each opto. That requires only 1.49ma per opto from the pis 5V rail for a total of 1.49ma x 8 = 11.92ma.
Hope you mean 3.3v there :-)

I've chatted to a few people about these boards - there are a few variants. Most are really aimed at the Arduino market with 5V inputs, but they suggest changing a resistor to make the LED in the optoisolator more reliable at 3.3v.

I looked at doing a project to build a relay board for the Pi, but you can't DIY it for anything near the price you can buy these boards off ebay for. It's quite sad, really.

-Gordon
--
Gordons projects: https://projects.drogon.net/

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

Re: Safely Interfacing 8 Relay Module via GPIO

Wed Jan 23, 2013 7:42 pm

[email protected] wrote:
Hope you mean 3.3v there :-)

I've chatted to a few people about these boards - there are a few variants. Most are really aimed at the Arduino market with 5V inputs, but they suggest changing a resistor to make the LED in the optoisolator more reliable at 3.3v.

I looked at doing a project to build a relay board for the Pi, but you can't DIY it for anything near the price you can buy these boards off ebay for. It's quite sad, really.

-Gordon
No, I do mean 5V :o . The opto will not work with a 3.3v supply voltage. It is an active low circuit, meaning that the anodes of all 8 optos are connected together to a single supply voltage pin internally on the circuit board (and you cannot separate them out), so you need to ground the cathode side of each opto to get each one to light up. This means you have two options to get it to work, either sink the current through a GPIO pin to ground or through a transistor to ground. I chose to use a transistor to keep the 3.3v of the GPIO circuitry isolated from the 5V supply of the opto circuit so there is no chance of making a costly mistake. I also prefer having an active high circuit. Here is my exact setup:

The GPIO pin is connected to the base of a transistor via a 2.2k resistor. A high state of the GPIO pin supplies 1.17ma to the base of the transistor to the emitter to ground. This turns on the collector to emitter connection where it sinks the current which is supplied from the 5v rail, (that current is 1.49 ma.), which turns on the opto led, which turns on the opto transistor, etc., etc. until it turns on the relay.

You are correct in that the resistor in the opto circuit is part of the problem as to why you can not sink enough current with a 3.3v supply to reliably light up the opto. The problem is that if you supply 3.3v to the opto circuit, the current must travel through a 1k ohm resistor, the opto led and an external led before it is sunk to ground. All those voltage drops and resistances are just too much to light up the opto led reliably. If I ground the opto circuit when supplying 3.3v (without using a transistor) I have verified this because I am only getting just 0.49 ma. I had considered changing the resistor, but I am not going to messing around with replacing 8 surface mount resistors.

Since you are the second person to state that there are different versions of this board, I can only definitively say that what I am stating applies to the Sainsmart 8 channel relay card ordered directly from Sainsmart (Model # 20-018-102) and sent via (in my case) a pretty fast boat from China.
Last edited by pjc123 on Wed Jan 23, 2013 7:59 pm, edited 1 time in total.
My Raspberry Pi Project Page:

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

User avatar
[email protected]
Posts: 2024
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK

Re: Safely Interfacing 8 Relay Module via GPIO

Wed Jan 23, 2013 7:54 pm

pjc123 wrote: The GPIO pin is connected to the base of a transistor via a 2.2k resistor. A high state of the GPIO pin supplies 1.17ma to the base of the transistor to the emitter to ground. This turns on the collector to emitter connection where it sinks the current which is supplied from the 5v rail, (that current is 1.49 ma.), which turns on the opto led, which turns on the opto transistor, etc., etc. until it turns on the relay.
I'd be careful here - if you reboot the Pi, the GPIOs will default to inputs and unless the internal pull-up/down resistors are activated (they are "rememberd" over a power cycle) the input pins are effectively floating, so stray capacitance could drive the transistors you're using and enable a relay. This may have unintended consequences. I'd be tempted to stick a 10K resistor to 0v at the gpio pin, or enable the internal pull-down resistors (Which are also 10K IIRC)
pjc123 wrote: You are correct in that the resistor in the opto circuit is part of the problem as to why you can not sink enough current with a 3.3v supply to reliably light up the opto. The problem is that if you supply 3.3v to the opto circuit, the current must travel through a 1k ohm resistor, the opto led and an external led before it is sunk to ground. All those voltage drops and resistances are just too much to light up the opto led reliably. If I ground the opto circuit when supplying 3.3v (without using a transistor) I have verified this because I am only getting just 0.49 ma. I had considered changing the resistor, but I am not going to messing around with replacing 8 surface mount resistors.
I do wonder about the "belt & braces" approach here though - opto isolators *and* relays. Since when did relays stop becoming good isolators between high voltage and low voltage systems.. Ah well!

-Gordon
--
Gordons projects: https://projects.drogon.net/

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

Re: Safely Interfacing 8 Relay Module via GPIO

Wed Jan 23, 2013 8:39 pm

[email protected] wrote: I'd be tempted to stick a 10K resistor to 0v at the gpio pin, or enable the internal pull-down resistors (Which are also 10K IIRC)
Thanks for that; it would indeed be very bad in my case if the relay tripped without my doing it on purpose in software. Since I haven't started to solder my final version yet, this is certainly addable, and I would feel better with using a physical external resistor not set in software. As a second layer of protection I also have picked GPIO ports that do not boot up in the high state. GPIO ports (not physical pins) 0, 1, 7, 8, 14 and 15 are all outputting 3.3 volts (or "HIGH") at boot. All other GPIO ports at boot are not "HIGH", although now I know that they are inputs and not "LOW" outputs and indeed could be floating. As a third layer of protection, the first thing I do when I enter my software code is to set up the pins I need as outputs and in a "LOW" state.

As a side note, although I have a Rev 1 board, I learned yesterday that there is a bug in the firmware that causes GPIO port 27 on the rev 2 board (Formerly GPIO port 21 on the rev1 board) to boot up active high, and a fix is in the works. This is important to me because I would like to eventually upgrade.

Since you are pretty aware of the pi chip circuitry and people keep asking me the same questions, am I correct in assuming that sinking 5V through the GPIO pin is not a good idea, or is it just an open collector circuit and really does not care about the voltage (assuming that the sinking current limit is not exceeded)? I am at least sure that outputting a high to the GPIO port would be very bad in my case because you would have 5 volts on one end of the opto circuit meeting 3v at the other end.
My Raspberry Pi Project Page:

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

deathtrap
Posts: 7
Joined: Wed Jan 23, 2013 2:57 am

Re: Safely Interfacing 8 Relay Module via GPIO

Wed Jan 23, 2013 9:29 pm

pjc123 wrote:
deathtrap wrote: Thank you for the information, is there any chance you could email me the schematics ([email protected])? I would really appreciate it. Thanks again!
Yes, I will email the schematic, circuit board drawing and technical specifications for the board to you. I found these floating around different places on the Internet; they are accurate for my Sainsmart board. As I recall some of it came from an Arduino forum. You will have a much better understanding of what is going on with the schematic. Just make sure that the components in the schematic exactly match your circuit board as was mentioned. If you have any other questions feel free to ask.

Update: sent.
Thank you very much for taking the time to email those .pdf files. I greatly appreciate it!

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

Re: Safely Interfacing 8 Relay Module via GPIO

Wed Jan 23, 2013 9:36 pm

deathtrap wrote: Thank you very much for taking the time to email those .pdf files. I greatly appreciate it!
Have fun.
My Raspberry Pi Project Page:

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

User avatar
[email protected]
Posts: 2024
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK

Re: Safely Interfacing 8 Relay Module via GPIO

Wed Jan 23, 2013 10:10 pm

pjc123 wrote: Since you are pretty aware of the pi chip circuitry and people keep asking me the same questions, am I correct in assuming that sinking 5V through the GPIO pin is not a good idea, or is it just an open collector circuit and really does not care about the voltage (assuming that the sinking current limit is not exceeded)? I am at least sure that outputting a high to the GPIO port would be very bad in my case because you would have 5 volts on one end of the opto circuit meeting 3v at the other end.
Indeed. Don't do it. When you're not "sinking it"... There's then 5v on an output pin connected to the Pi's 3.3v supply...

-Gordon
--
Gordons projects: https://projects.drogon.net/

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

Re: Safely Interfacing 8 Relay Module via GPIO

Wed Jan 23, 2013 10:22 pm

[email protected] wrote:
pjc123 wrote: Since you are pretty aware of the pi chip circuitry and people keep asking me the same questions, am I correct in assuming that sinking 5V through the GPIO pin is not a good idea, or is it just an open collector circuit and really does not care about the voltage (assuming that the sinking current limit is not exceeded)? I am at least sure that outputting a high to the GPIO port would be very bad in my case because you would have 5 volts on one end of the opto circuit meeting 3v at the other end.
Indeed. Don't do it. When you're not "sinking it"... There's then 5v on an output pin connected to the Pi's 3.3v supply...

-Gordon
That is why I recommend using a transistor (High, Low, whatever.....no damage). But, even though I don't want to do it, I still wonder if it would it be OK to sink the 5 Volts? I have a feeling that is what some people are doing to get the board to work, at least until they accidentally send a high signal out.
My Raspberry Pi Project Page:

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

User avatar
abishur
Posts: 4501
Joined: Thu Jul 28, 2011 4:10 am
Location: USA

Re: Safely Interfacing 8 Relay Module via GPIO

Wed Jan 23, 2013 10:27 pm

[email protected] wrote: I do wonder about the "belt & braces" approach here though - opto isolators *and* relays. Since when did relays stop becoming good isolators between high voltage and low voltage systems.. Ah well!
-Gordon
My guess is that a regular relay stopped being good enough when it stopped just being a matter of low to high voltage, but also a matter of very low current with low margins of tolerance. Also there was probably some good marketing around the time SSRs hit the scene, and the humble regular relay started to get slammed (after all a regular relay might one day get stuck since its mechanical).
[email protected] wrote: I looked at doing a project to build a relay board for the Pi, but you can't DIY it for anything near the price you can buy these boards off ebay for. It's quite sad, really.
-Gordon
It really is... but not quite so sad that it prevented me from buying the SSR version of their board of ebay :lol: I can't even buy 8 SSRs with those specs for under 20 USD! (it cost 20 USD) :shock: And yes I can't help but notice the irony of my previous paragraph in conjunction with the fist one ;-) But while I do like SSRs over mechanical relays for long term projects involving PC level voltages, the thing that won me over was the circuit diagram for the SSR model, it looks like has built in transistors that can be activated by the pi's humble 3v3 GPIO.
Dear forum: Play nice ;-)

User avatar
abishur
Posts: 4501
Joined: Thu Jul 28, 2011 4:10 am
Location: USA

Re: Safely Interfacing 8 Relay Module via GPIO

Wed Jan 23, 2013 10:32 pm

pjc123 wrote:
[email protected] wrote:
pjc123 wrote: Since you are pretty aware of the pi chip circuitry and people keep asking me the same questions, am I correct in assuming that sinking 5V through the GPIO pin is not a good idea, or is it just an open collector circuit and really does not care about the voltage (assuming that the sinking current limit is not exceeded)? I am at least sure that outputting a high to the GPIO port would be very bad in my case because you would have 5 volts on one end of the opto circuit meeting 3v at the other end.
Indeed. Don't do it. When you're not "sinking it"... There's then 5v on an output pin connected to the Pi's 3.3v supply...

-Gordon
That is why I recommend using a transistor (High, Low, whatever.....no damage). But, even though I don't want to do it, I still wonder if it would it be OK to sink the 5 Volts? I have a feeling that is what some people are doing to get the board to work, at least until they accidentally send a high signal out.
Well its your pi so you can do what you want, but I strongly recommend against sinking 5V to the GPIO pins. Those GPIO go straight to the ARM processor which is designed to only handle 3v3 levels. Even if it works in the short term the chip just isn't meant to handle it. I think I bought a darlington transistor array from a local electronic shop for under a buck, it's worth using it in the long term of your pi ;-)
Dear forum: Play nice ;-)

User avatar
[email protected]
Posts: 2024
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK

Re: Safely Interfacing 8 Relay Module via GPIO

Wed Jan 23, 2013 10:37 pm

pjc123 wrote:
[email protected] wrote:
pjc123 wrote: Since you are pretty aware of the pi chip circuitry and people keep asking me the same questions, am I correct in assuming that sinking 5V through the GPIO pin is not a good idea, or is it just an open collector circuit and really does not care about the voltage (assuming that the sinking current limit is not exceeded)? I am at least sure that outputting a high to the GPIO port would be very bad in my case because you would have 5 volts on one end of the opto circuit meeting 3v at the other end.
Indeed. Don't do it. When you're not "sinking it"... There's then 5v on an output pin connected to the Pi's 3.3v supply...

-Gordon
That is why I recommend using a transistor (High, Low, whatever.....no damage). But, even though I don't want to do it, I still wonder if it would it be OK to sink the 5 Volts? I have a feeling that is what some people are doing to get the board to work, at least until they accidentally send a high signal out.
How do you propose to stop sinking the 5v (into the Pi) then? You do that by 2 ways: 1 you set the output high (which is what you'd do normally), or 2, you change the pin mode to input.

Either way, you then have 5v on the pin and that will end in tears.

Personally, I'd not touch this board at all - I'd build something myself, however the easiest way to drive it would be to use something like a ULN2803 rather than mess about with 8 discrete transitors and 16 resistors (Which is what I'd use to directly drive the relays anyway without faffing with the opto isolators, but hey...)

Note the gertboard has a uln2003 chip marked "relay" and the PiFace board has a uln2803 driving 2 relays and 6 other uncomitted outputs... Realys + optoisolators ... belt & braces, but are they really needed or are they just overcomplicating things?

-Gordon
--
Gordons projects: https://projects.drogon.net/

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

Re: Safely Interfacing 8 Relay Module via GPIO

Wed Jan 23, 2013 10:53 pm

Sorry I brought it up. I was just wondering of these claims of people directly connecting the board to the pi without additional circuitry. They must be sinking into the pi, and yes, as I suspected that is bad. Outputting a "LOW' or "HIGH" to the transistor from the GPIO works fine for me; it has been running for several months now, so I am good.

In addition to the relay card, I actually also use a ULN2803A to control a single high coil current relay that I have (30 amp contacts at 250 Vac). In front of that is an opto that only requires only 1.6ma to operate, so it can run directly from the GPIO pins. Yes, I know, overkill on the protection.
Last edited by pjc123 on Wed Jan 23, 2013 11:09 pm, edited 1 time in total.
My Raspberry Pi Project Page:

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

User avatar
[email protected]
Posts: 2024
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK

Re: Safely Interfacing 8 Relay Module via GPIO

Wed Jan 23, 2013 11:04 pm

pjc123 wrote:Sorry I brought it up. I was just wondering of these claims of people directly connecting the board to the pi without additional circuitry. They must be sinking into the pi, and yes, as I suspected that is bad. Outputting a "LOW' or "HIGH" to the transistor from the GPIO works fine for me; it has been running for several months now, so I am good.
Ah ok. Thought you were in the middle of building it up.

Glad it's working OK.

-Gordon
--
Gordons projects: https://projects.drogon.net/

Return to “HATs and other add-ons”