Matrim_Cauthon91
Posts: 10
Joined: Fri Jul 03, 2020 2:35 pm

5V Relay without transistor?

Fri Jun 04, 2021 12:48 pm

Is it possible to use a 5V Relay without a transistor? (Relay is a SRD-05VDC-SL-C)

I have basically followed this example but instead of 8 relays I am using 1 to control a solenoid pinch valve - https://www.instructables.com/A-Raspber ... m-Machine/

However, the issue I have is when I set the GPIO to HIGH the relay turns on (Green light) and the pinch valve is activated (I can see this) - but when I try to turn the GPIO to LOW (after a 5 second delay) nothing happens. Using GPIO.cleanup turns the relay (and valve) off.

The only fix I can find for this is connecting to the relay through a transistor.

Is there another solution and why would the example with the 8 relays NOT require anything else (i.e. transistor or resistor pulldown.pullup)?

Thanks.

LTolledo
Posts: 5563
Joined: Sat Mar 17, 2018 7:29 am
Location: Anime Heartland

Re: 5V Relay without transistor?

Fri Jun 04, 2021 1:16 pm

the 8-relay module pictured in the instructibles already has those transistors, resistors, flyback diodes, and with additional opto-couplers, all included on the board

I know because I actually own one of those modules, as well as singles, duals, quads, and 16s

maybe this is what you need for your single solenoid use:
HW307 relay board.jpg
HW307 relay board.jpg (187.81 KiB) Viewed 811 times
this type has no optocoupler...
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

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

Re: 5V Relay without transistor?

Sat Jun 05, 2021 8:04 am

Matrim_Cauthon91 wrote:
Fri Jun 04, 2021 12:48 pm
Is it possible to use a 5V Relay without a transistor? (Relay is a SRD-05VDC-SL-C)
Is your relay just a relay on its own or is it mounted on a PCB with some other components ?

Because what you describe in its operation suggests it actually an active low relay , so you should be setting the gpio low to turn it on , but the 3.3v of the gpio is no sufficient to be able to turn the relay off because the control circuit is being powered by 5V.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 14057
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: 5V Relay without transistor?

Sat Jun 05, 2021 2:56 pm


Matrim_Cauthon91
Posts: 10
Joined: Fri Jul 03, 2020 2:35 pm

Re: 5V Relay without transistor?

Mon Jun 07, 2021 1:41 pm

Thanks for your replies! I read the issues with the relay and that seems to be the problem.

Just a quick question the person who created the drum machine in the original post also put diodes in his system - however the relays are optocoupled and you mentioned those relays already have a diode integrated so are the diodes still required if this is the case?

Unfortunately that relay is no longer available from ali express however this is a similar one - https://www.switchelectronics.co.uk/5v- ... escription

Would I still need the 'external' diodes if the relay already has them?

Thanks again for the help!

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

Re: 5V Relay without transistor?

Mon Jun 07, 2021 1:52 pm

So if you relay is on a PCB with a driver circuit then no you will not need to add a back emf diode there will already be on on the board.

I suggest you post pictures of the board you have as it will help us identify what you actually have.

But as I said its sounds like you have an active low board with a 5V control circuit so you will probably need a transistor interface circuit between the pi 3.3V gpio and the relay board.

Once I know which board you have I can post a diagram of what's required.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Matrim_Cauthon91
Posts: 10
Joined: Fri Jul 03, 2020 2:35 pm

Re: 5V Relay without transistor?

Mon Jun 07, 2021 2:30 pm

This is the exact relay I purchased - https://www.aliexpress.com/item/3295578 ... 719de4e665

The circuit is not on a PCB (that is the next step) - currently it is just wired as is shown here - https://www.instructables.com/A-Raspber ... m-Machine/

I wanted to test the relay/ solenoid valve so I connected one relay with one solenoid (instead of 8 with 8)
Untitled.jpg
Untitled.jpg (38.22 KiB) Viewed 663 times
. - I think this may have been the issue I had earlier in the Original post with 'LOW' not turning the solenoid off.

However, I have the 8 version relay and is what I will be using. Ideally I would create a PCB with the diodes in the PCB - however if the 8 relay already has these diodes then I wont need the PCB/diodes?

Matrim_Cauthon91
Posts: 10
Joined: Fri Jul 03, 2020 2:35 pm

Re: 5V Relay without transistor?

Mon Jun 07, 2021 2:41 pm

Or would I better just getting this?

https://thepihut.com/products/8-channel ... spberry-pi

Thanks again for the support with this!!!

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

Re: 5V Relay without transistor?

Mon Jun 07, 2021 2:49 pm

So the relay board in the picture has a control circuit on the PCB which includes the back emf diode,
to protect the circuit form the back emf of the relay coil.

its the small components below the relay ( blue block) in your picture.

The extra external circuit required is to interface the pi 3.3v gpio to the 5V relay board to make the relay work correctly.

for a single relay board it would look like this

Image

For an 8 way relay board I would suggest you use a ULN2803A as this requires no extra components.

Image

and I suggest you use an external 5V supply to power the relay board rather than trying to power it from the 5V pin on the pi.
Last edited by pcmanbob on Mon Jun 07, 2021 3:00 pm, edited 1 time in total.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

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

Re: 5V Relay without transistor?

Mon Jun 07, 2021 2:59 pm

Now the solenoid / relay contact circuit will require a back EMF diode to protect the relay contacts for burning.

Don't confuse this with the one on the relay board in the control circuit.

it should look like this

Image
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Matrim_Cauthon91
Posts: 10
Joined: Fri Jul 03, 2020 2:35 pm

Re: 5V Relay without transistor?

Mon Jun 07, 2021 4:24 pm

pcmanbob wrote:
Mon Jun 07, 2021 2:59 pm
Now the solenoid / relay contact circuit will require a back EMF diode to protect the relay contacts for burning.

Don't confuse this with the one on the relay board in the control circuit.

it should look like this

Image
and this is for the '8-Channel Relay Expansion Board for Raspberry Pi' ?

Trying to figure what would be a better option.


Thanks again!

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

Re: 5V Relay without transistor?

Mon Jun 07, 2021 4:35 pm

Matrim_Cauthon91 wrote:
Mon Jun 07, 2021 4:24 pm
pcmanbob wrote:
Mon Jun 07, 2021 2:59 pm
Now the solenoid / relay contact circuit will require a back EMF diode to protect the relay contacts for burning.

Don't confuse this with the one on the relay board in the control circuit.

it should look like this

Image
and this is for the '8-Channel Relay Expansion Board for Raspberry Pi' ?

Trying to figure what would be a better option.


Thanks again!
This circuit is required on each solenoid regardless of the number of relays used .

So if you were driving 1 or 8 you will have this circuit on each output so you could have 8 copies of this circuit.

Even if you us a different relay board you would still need this diode on each output.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

drtechno
Posts: 261
Joined: Fri Apr 09, 2021 6:33 pm

Re: 5V Relay without transistor?

Mon Jun 07, 2021 5:47 pm

Matrim_Cauthon91 wrote:
Fri Jun 04, 2021 12:48 pm
Is it possible to use a 5V Relay without a transistor? (Relay is a SRD-05VDC-SL-C)

I have basically followed this example but instead of 8 relays I am using 1 to control a solenoid pinch valve - https://www.instructables.com/A-Raspber ... m-Machine/

However, the issue I have is when I set the GPIO to HIGH the relay turns on (Green light) and the pinch valve is activated (I can see this) - but when I try to turn the GPIO to LOW (after a 5 second delay) nothing happens. Using GPIO.cleanup turns the relay (and valve) off.

The only fix I can find for this is connecting to the relay through a transistor.

Is there another solution and why would the example with the 8 relays NOT require anything else (i.e. transistor or resistor pulldown.pullup)?

Thanks.
In your example with 8 relays they are using a transistor out opto isolator to drive the relay.
the only ones that you could get away with using would be a reed relay or a telcom ic relay.
But if you want to know, an n-channel enhancement mode mosfet is the better relay driver than a transistor on this platform.

twostage
Posts: 125
Joined: Sun May 07, 2017 6:31 pm
Location: Northumberland

Re: 5V Relay without transistor?

Tue Jun 15, 2021 8:13 am

Matrim_Cauthon91 wrote:
Fri Jun 04, 2021 12:48 pm
Is it possible to use a 5V Relay without a transistor? (Relay is a SRD-05VDC-SL-C)

I have basically followed this example but instead of 8 relays I am using 1 to control a solenoid pinch valve - https://www.instructables.com/A-Raspber ... m-Machine/

However, the issue I have is when I set the GPIO to HIGH the relay turns on (Green light) and the pinch valve is activated (I can see this) - but when I try to turn the GPIO to LOW (after a 5 second delay) nothing happens. Using GPIO.cleanup turns the relay (and valve) off.

The only fix I can find for this is connecting to the relay through a transistor.

Is there another solution and why would the example with the 8 relays NOT require anything else (i.e. transistor or resistor pulldown.pullup)?





Thanks.
If high turns it on and clean up turns it off is there a reason why you don't use this method anyway ? I know it's not nice, but on is output high, off is clean up from your description.

I know it goes outside of your no external components requirement but I stumbled on using two diodes in series between the gpio and the relay and switching between output high and input to turn relays on and off. Simple to wire.

Matrim_Cauthon91
Posts: 10
Joined: Fri Jul 03, 2020 2:35 pm

Re: 5V Relay without transistor?

Fri Jun 18, 2021 12:04 pm

So I bought the transistor and everything is working great!

Now going to try the next step of moving from breadboard to PCB/Assembly.

Not sure if anyone has any experience of having one made/ making their own.

But just wanted to quickly check what I have done.

Image

Labels on the Schematic:

CN1 = 40 pin male header
Q2 = ULN2803A transistor
H2 = 10 pin male header
DC1 = 5V DC connector socket
H3 = 3 pin male header

I am hoping that once printed a ribbon cable will connect the Raspberry Pi to the CN1.
8 jumper cables will connect the H2 to the 8 channel relay.
2 jumper cables will connect the H3 to the GND & VCC on the 8 channel relay.

Does anything look wrong here?

Thanks again.
Attachments
Schematic_VAC Schematic_2021-06-18 (2).png
Schematic_VAC Schematic_2021-06-18 (2).png (24.24 KiB) Viewed 293 times

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

Re: 5V Relay without transistor?

Fri Jun 18, 2021 12:34 pm

The only thing I see is a missing link between 5V and Vcc-JD , unless you still have the jumper on VCC & Vcc-JD.

I would advise you to solder a socket on your PCB and fit the ULN2803A after soldering , so you don't risk damaging the chip by over heating it while soldering.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Return to “Automation, sensing and robotics”