sgraphics
Posts: 4
Joined: Tue Aug 18, 2020 6:34 am

Running 5V solenoid straight off of Pi using a relay

Tue Aug 18, 2020 6:52 am

Hi,

I'm new to this and would like to validate a scenario before doing anything. I already managed to fry one Pi last month :)

Can I run a 5V solenoid straight off of Pi using a relay (without additional breakout board, diodes or transistors)?

Products:
Board: Raspberry Pi 4B
Solenoid: https://www.adafruit.com/product/3992
Relay board: https://thepihut.com/products/raspberry-pi-relay-board

By default they propose this setup: https://cdn-shop.adafruit.com/product-f ... driver.pdf ("These draw quite a bit of current, 800mA at 5V and 1 Amp at 6V so you'll want a good strong driver.")

But would this set up work? As I understand Pi as well has 5V outs, so why not drive it directly?
solenoid.png
solenoid.png (7.04 KiB) Viewed 489 times

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

Re: Running 5V solenoid straight off of Pi using a relay

Tue Aug 18, 2020 8:00 am

Hi.

Yes the relay board will work correctly with the pi no other components required,

As to powering the solenoid directly from the pi ,

it will depend on how go the power supply is you are powering your pi from , and what else is drawing power from the 5V rail ( your relay board for example ).

You may find that when you activate your solenoid you pi crashes or even reboots due to the sudden load place on the 5V rail .

If this happens you will need a separate power supply for the solenoid.

Your diagram is also wrong this is how it should be connected, and I recommend a diode be connected as shown to protect the relay contacts from the reverse voltage spike on solenoid power off.

Image

connections to the gpio pins to control the relays are made by the fact that the relay board plugs directly on to the pi gpio pins.

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

sgraphics
Posts: 4
Joined: Tue Aug 18, 2020 6:34 am

Re: Running 5V solenoid straight off of Pi using a relay

Tue Aug 18, 2020 8:03 am

Thanks for the reply! I cannot see the images you posted though - they dont seem to be loading

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

Re: Running 5V solenoid straight off of Pi using a relay

Tue Aug 18, 2020 8:15 am

sgraphics wrote:
Tue Aug 18, 2020 8:03 am
Thanks for the reply! I cannot see the images you posted though - they dont seem to be loading
I never normally have any problems with posting images on the forum, I do it all the time.

but here are direct links to them.

https://i.imgur.com/Tb542KV.jpg

https://i.imgur.com/4Aa4Vox.jpg

which I checked and work so if you still cant see them the problem is at your end
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

sgraphics
Posts: 4
Joined: Tue Aug 18, 2020 6:34 am

Re: Running 5V solenoid straight off of Pi using a relay

Tue Aug 18, 2020 11:08 am

Hi, you are right problem was on my end (proxy). Thanks for the thorough explanation!

sgraphics
Posts: 4
Joined: Tue Aug 18, 2020 6:34 am

Re: Running 5V solenoid straight off of Pi using a relay

Tue Aug 18, 2020 11:31 am

Btw, can I use a 1N4007 (1N4007 Si-D 1000V 1A) diode instead of a 1N4001 one for the safety? Can't seem to find 1N4001 anywhere locally..

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

Re: Running 5V solenoid straight off of Pi using a relay

Tue Aug 18, 2020 12:01 pm

sgraphics wrote:
Tue Aug 18, 2020 11:31 am
Btw, can I use a 1N4007 (1N4007 Si-D 1000V 1A) diode instead of a 1N4001 one for the safety? Can't seem to find 1N4001 anywhere locally..
Yes, the 1N4007 just is able to withstand a higher reverse voltage (1000V) than the 1N4001.

emma1997
Posts: 868
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not that old one)

Re: Running 5V solenoid straight off of Pi using a relay

Tue Aug 18, 2020 4:33 pm

I don't think a single 1n4001 has been manufactured in decades. They may be marked 1n4001 or 1n4002 or 1n4004 etc but in fact all are 1n4007 die relabeled. This was confirmed in an EEVblog thread few years back where many samples from many sources were characterized and compared with vintage parts. Conclusion was the last time real 1n4001 were made and sold was about 20yrs ago and at that time they actually cost more than 1n4007.

With modern transistors and proper software it's debatable whether EMF diodes are needed and in fact much evidence indicates can do more harm than good.

drgeoff
Posts: 10831
Joined: Wed Jan 25, 2012 6:39 pm

Re: Running 5V solenoid straight off of Pi using a relay

Tue Aug 18, 2020 7:04 pm

emma1997 wrote:
Tue Aug 18, 2020 4:33 pm
With modern transistors and proper software it's debatable whether EMF diodes are needed and in fact much evidence indicates can do more harm than good.
Even if your assertion were true (which is another argument I'm not starting) the diode that pcmanbob advocates is protecting relay contacts not transistors.
Quis custodiet ipsos custodes?

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

Re: Running 5V solenoid straight off of Pi using a relay

Tue Aug 18, 2020 7:27 pm

The diode prevents a very high voltage over the coil when current through the coil is abruptly shut down.
It depends on what is connected to the coil ends if the diode is removed what will be blown up, but I have learned that it is most often the transistor that tries to switch off the current that is the victim, but if the coil current is switched with relay contacts you are right.

User avatar
PeterO
Posts: 5951
Joined: Sun Jul 22, 2012 4:14 pm

Re: Running 5V solenoid straight off of Pi using a relay

Tue Aug 18, 2020 7:54 pm

As a matter of principle I would never drive any large inductive load like a solenoid from the Pi's 5V supply.
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

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

Re: Running 5V solenoid straight off of Pi using a relay

Tue Aug 18, 2020 7:57 pm

If you have ever looked at a set of relay contact that have been switching an inductive load you would see how much damage they can suffer.

That's why I suggested the diode.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

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

Re: Running 5V solenoid straight off of Pi using a relay

Tue Aug 18, 2020 8:03 pm

PeterO wrote:
Tue Aug 18, 2020 7:54 pm
As a matter of principle I would never drive any large inductive load like a solenoid from the Pi's 5V supply.
PeterO
I did say it was not recommended, but I guess the OP can do what they wish its their pi to damage.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
PeterO
Posts: 5951
Joined: Sun Jul 22, 2012 4:14 pm

Re: Running 5V solenoid straight off of Pi using a relay

Tue Aug 18, 2020 8:31 pm

pcmanbob wrote:
Tue Aug 18, 2020 8:03 pm
PeterO wrote:
Tue Aug 18, 2020 7:54 pm
As a matter of principle I would never drive any large inductive load like a solenoid from the Pi's 5V supply.
PeterO
I did say it was not recommended, but I guess the OP can do what they wish its their pi to damage.
I'm agreeing with you so not sure what your "I did say....." is about ?
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

Brandon92
Posts: 870
Joined: Wed Jul 25, 2018 9:29 pm
Location: The Netherlands

Re: Running 5V solenoid straight off of Pi using a relay

Tue Aug 18, 2020 8:43 pm

I'm also wondering if the inrush current of that solenoid will be a problem for the Rpi. This may give a "large" voltage drop in the 5V rail and the Rpi doesn't like that.

User avatar
PeterO
Posts: 5951
Joined: Sun Jul 22, 2012 4:14 pm

Re: Running 5V solenoid straight off of Pi using a relay

Tue Aug 18, 2020 8:53 pm

Brandon92 wrote:
Tue Aug 18, 2020 8:43 pm
I'm also wondering if the inrush current of that solenoid will be a problem for the Rpi. This may give a "large" voltage drop in the 5V rail and the Rpi doesn't like that.
A solenoid is an inductor not a capacitor !

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

Brandon92
Posts: 870
Joined: Wed Jul 25, 2018 9:29 pm
Location: The Netherlands

Re: Running 5V solenoid straight off of Pi using a relay

Tue Aug 18, 2020 8:58 pm

PeterO wrote:
Tue Aug 18, 2020 8:53 pm
Brandon92 wrote:
Tue Aug 18, 2020 8:43 pm
I'm also wondering if the inrush current of that solenoid will be a problem for the Rpi. This may give a "large" voltage drop in the 5V rail and the Rpi doesn't like that.
A solenoid is an inductor not a capacitor !

PeterO
:x Indeed, I think I need to go to bed :?

Return to “Other projects”