Learning101
Posts: 20
Joined: Sat Feb 10, 2018 10:54 am

GPIO to 5V Relay - 24VAC Solenoid

Sat Feb 10, 2018 10:59 am

Hi, I'm trying to get a project together and I need to power a 24vac solenoid for short periods.

I understand the easiest off the shelf way is with a relay, (please correct me if I'm wrong)

Would this relay be suitable? https://www.amazon.co.uk/Elegoo-Channel ... B06XK6HCQC

It does say 5v and I know the GPIO is 3.3v but I don't seem to be able to find 3.3V relays! Would it still work?

Any advise greatly appreciated.
Thanks

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

Re: GPIO to 5V Relay - 24VAC Solenoid

Sat Feb 10, 2018 11:19 pm

The relay board you have chosen may work, some of these 5V relay boards do work with the pi gpio and some don't, it seems to be pot luck as to whether they work or not.

You can always make them work and be active high with a simple transistor & resistor interface for each relay input.
Please only ask questions in the forum I will not answer questions sent to me directly via PM
Remember we want information.......................no information no help
The use of crystal balls & mind reading is not supported

klricks
Posts: 5393
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: GPIO to 5V Relay - 24VAC Solenoid

Sun Feb 11, 2018 12:36 am

Learning101 wrote:
Sat Feb 10, 2018 10:59 am
Hi, I'm trying to get a project together and I need to power a 24vac solenoid for short periods.

I understand the easiest off the shelf way is with a relay, (please correct me if I'm wrong)

Would this relay be suitable? https://www.amazon.co.uk/Elegoo-Channel ... B06XK6HCQC

It does say 5v and I know the GPIO is 3.3v but I don't seem to be able to find 3.3V relays! Would it still work?

Any advise greatly appreciated.
Thanks
Do not confuse the relay coil voltage with the input control voltage. The relay coils are made with many different voltages. 3,5,6,12,24 etc. When they say 'x Volt relay' they are usually referring to the coil voltage not the input control voltage.
Most all the relay boards have control inputs which operate at 5V logic levels regardless of what the coil voltage is. (except automotive which are 12 or 24V)

For use with the RPi, 5V relays are convenient because the RPi has available a 5V supply.
(Note that even if you find a 3V relay the RPi GPIO could not handle the required current load).

In theory a 3V3 device such a the RPi GPIO should be able to control a 5V input because anything over 2.0V is considered a HIGH logic level for both 3V3 and 5V devices.

In practice however it does not always work.
Unless specified otherwise my response is based on the latest and fully updated Raspbian Stretch w/ Desktop OS.

Learning101
Posts: 20
Joined: Sat Feb 10, 2018 10:54 am

Re: GPIO to 5V Relay - 24VAC Solenoid

Sun Feb 11, 2018 7:14 pm

pcmanbob wrote:
Sat Feb 10, 2018 11:19 pm
The relay board you have chosen may work, some of these 5V relay boards do work with the pi gpio and some don't, it seems to be pot luck as to whether they work or not.

You can always make them work and be active high with a simple transistor & resistor interface for each relay input.
Thanks for you help, if it worked without the transistor and resistor, would there be anything else I need to put between the PI and the relay? Or not?

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

Re: GPIO to 5V Relay - 24VAC Solenoid

Sun Feb 11, 2018 8:45 pm

If it works many people do just use the boards without any extra interfacing , but then you will find the board is what the call active low, so when you put a high on the gpio pin it will turn the relay off and when you put a low on the gpio pin you will turn the relay on.

while this works it can cause problems when you are booting the pi as the relay will be active while you are booting and you are using the gpio as a ground for the 5v that the opto-isolators work with which I don't think is a good idea.

My advice try it and see then make up your own mind if you wan to add the extra interfacing components.
Please only ask questions in the forum I will not answer questions sent to me directly via PM
Remember we want information.......................no information no help
The use of crystal balls & mind reading is not supported

Learning101
Posts: 20
Joined: Sat Feb 10, 2018 10:54 am

Re: GPIO to 5V Relay - 24VAC Solenoid

Tue Feb 13, 2018 10:21 pm

That's for the help,

My next challenge is that I want to connect up some solenoids. I have 4 coil solenoids but there is no specs available, is there any way to test what power to use?

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

Re: GPIO to 5V Relay - 24VAC Solenoid

Tue Feb 13, 2018 11:29 pm

If you know what voltage they operate at then it's a simple thing to if they work on DC as you can use a simple multimeter set to amps to measure the current drawn, but your original post said 24v AC to measure AC amps you will need a clipon ammeter.

You could get estimated current if you know the operating voltage and you can measure the coil resistance using voltage / resistance = Current.

Can you give use any information on the solenoid valve you are using
Make, model, supplier ?
Please only ask questions in the forum I will not answer questions sent to me directly via PM
Remember we want information.......................no information no help
The use of crystal balls & mind reading is not supported

Learning101
Posts: 20
Joined: Sat Feb 10, 2018 10:54 am

Re: GPIO to 5V Relay - 24VAC Solenoid

Fri Feb 16, 2018 6:04 pm

pcmanbob wrote:
Tue Feb 13, 2018 11:29 pm
If you know what voltage they operate at then it's a simple thing to if they work on DC as you can use a simple multimeter set to amps to measure the current drawn, but your original post said 24v AC to measure AC amps you will need a clipon ammeter.

You could get estimated current if you know the operating voltage and you can measure the coil resistance using voltage / resistance = Current.

Can you give use any information on the solenoid valve you are using
Make, model, supplier ?
Hi, so the solenoids are salvaged off a Coinco Global 2 coin mech, MDB version.

http://www.jemphrey.com/images/Guides/G ... manual.pdf

The solenoids themselves have no markings, the coin changer says it takes 34V DC to power normally from a vending machine.

They are very small solenoids, with very thin wire.

What would you suggest I do to power them sufficiently?

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

Re: GPIO to 5V Relay - 24VAC Solenoid

Fri Feb 16, 2018 7:38 pm

The problem you face with the solenoids having no markings is that even if the coin mech is powered from 34v DC there is nothing to say the solenoids will also be powered from the same 34v DC the coin mech may have output a different voltage to drive them.

So what you could do is using a digital multi meter set on ohms measure the resistance of the coil., then using different voltages
use the formula voltage / resistance = Current to work out the current that will flow for a given voltage.

if you say the wire is very thin then your probable want a current of maybe 100 -500 ma to flow ( thats 0.1 to 0.5 A )
this way you could get an estimate of the required voltage to operate the solenoid.

I would suggest you try voltages of 6,12,18,24,34V

once you have an idea of the voltage you can but test a solenoid and see if it works, but I would be ready to disconnect the power in the even you have it wrong and things start to smoke, it going to be a case of trail and error so be prepared for failure.
Please only ask questions in the forum I will not answer questions sent to me directly via PM
Remember we want information.......................no information no help
The use of crystal balls & mind reading is not supported

Learning101
Posts: 20
Joined: Sat Feb 10, 2018 10:54 am

Re: GPIO to 5V Relay - 24VAC Solenoid

Fri Feb 16, 2018 9:57 pm

pcmanbob wrote:
Fri Feb 16, 2018 7:38 pm
The problem you face with the solenoids having no markings is that even if the coin mech is powered from 34v DC there is nothing to say the solenoids will also be powered from the same 34v DC the coin mech may have output a different voltage to drive them.

So what you could do is using a digital multi meter set on ohms measure the resistance of the coil., then using different voltages
use the formula voltage / resistance = Current to work out the current that will flow for a given voltage.

if you say the wire is very thin then your probable want a current of maybe 100 -500 ma to flow ( thats 0.1 to 0.5 A )
this way you could get an estimate of the required voltage to operate the solenoid.

I would suggest you try voltages of 6,12,18,24,34V

once you have an idea of the voltage you can but test a solenoid and see if it works, but I would be ready to disconnect the power in the even you have it wrong and things start to smoke, it going to be a case of trail and error so be prepared for failure.
Hi Thanks, what is the best way to supply 6v, would it be with an adapter like this,

http://cpc.farnell.com/powerpax/std-061 ... gLn4vD_BwE

And would I need anything in between this and the solenoid to protect the power source?

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

Re: GPIO to 5V Relay - 24VAC Solenoid

Fri Feb 16, 2018 10:09 pm


MarkR
Posts: 122
Joined: Fri Jan 25, 2013 1:55 pm

Re: GPIO to 5V Relay - 24VAC Solenoid

Fri Feb 16, 2018 11:30 pm

I'm not convinced that you'll be able to drive any relay with the weak gpio outputs on the Pi.

I'd recommend either an npn^Wpnp^Wnpn^WI don't know what kind/ transistor or a mosfet to drive the relay; if you electronically switch the "low side" and have the "high side" of the relay coil on a higher voltage (e.g. 5v) I don't think you'll damage the Pi.

I think it's a good idea to use low-side switching to keep the pi referenced to a reasonable voltage if you need to drive the load higher.

Also it's better to not put too much load on the Pi's voltage regulator.

Please ignore my suggestion on the transistor circuit and make your own based on superior knowledge (not difficult). Don't let the Pi output exceed 3v3 and don't let it take more current than recommended. If you use a BJT transistor put a nice big current limiting resistor.

Learning101
Posts: 20
Joined: Sat Feb 10, 2018 10:54 am

Re: GPIO to 5V Relay - 24VAC Solenoid

Sat Feb 17, 2018 8:08 am

I have the relay working using this setup,

https://docs.google.com/file/d/0B5-HND9 ... VyODA/edit

My next hurdle now is connecting the solenoid correctly to power, without knowing the specs of the solenoid. It is a very small solenoid, with very thin wire.

I will have a look at the suggestions above, I suppose if I under power the solenoid I will just get reduced performance?

Is it just a case of connecting the solenoid to power, or do I need to add anything to protect it when using the relay?

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

Re: GPIO to 5V Relay - 24VAC Solenoid

Sat Feb 17, 2018 10:32 am

Learning101 wrote:
Fri Feb 16, 2018 9:57 pm
what is the best way to supply 6v, would it be with an adapter like this,
And would I need anything in between this and the solenoid to protect the power source?
Have you done the calculations I suggested and decided that 6v is the correct voltage to use or are you just guessing ?

If 6v is the correct voltage to power your solenoid and the current draw by each is less that 0.5A then yes that would probably do the job.

once you know the current drawn you can put a fuse in the feed to your solenoid to protect it.
Please only ask questions in the forum I will not answer questions sent to me directly via PM
Remember we want information.......................no information no help
The use of crystal balls & mind reading is not supported

Learning101
Posts: 20
Joined: Sat Feb 10, 2018 10:54 am

Re: GPIO to 5V Relay - 24VAC Solenoid

Mon Feb 19, 2018 5:55 pm

pcmanbob wrote:
Sat Feb 17, 2018 10:32 am
Learning101 wrote:
Fri Feb 16, 2018 9:57 pm
what is the best way to supply 6v, would it be with an adapter like this,
And would I need anything in between this and the solenoid to protect the power source?
Have you done the calculations I suggested and decided that 6v is the correct voltage to use or are you just guessing ?

If 6v is the correct voltage to power your solenoid and the current draw by each is less that 0.5A then yes that would probably do the job.

once you know the current drawn you can put a fuse in the feed to your solenoid to protect it.
Yes the 6v was a guess, I was just checking that I understood what sort of power supply I might possibly need.

I have been trying to test the resistance with the multimeter, I have the meter set to 200, the lowest setting. But it just shows 1 it does not display a reading.

Does that mean the resistance is too low for my multimeter?

klricks
Posts: 5393
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: GPIO to 5V Relay - 24VAC Solenoid

Mon Feb 19, 2018 6:11 pm

Learning101 wrote:
Mon Feb 19, 2018 5:55 pm
...
I have been trying to test the resistance with the multimeter, I have the meter set to 200, the lowest setting. But it just shows 1 it does not display a reading.

Does that mean the resistance is too low for my multimeter?
Not possible for resistance to be too low for a reading. Though many cheap meters are not accurate when measuring low resistance, the meter should read 0.xxx. Touch the meter leads together to test.

A '1' displayed usually means infinite resistance or an open circuit OR the scale is set too low.
Unless specified otherwise my response is based on the latest and fully updated Raspbian Stretch w/ Desktop OS.

Learning101
Posts: 20
Joined: Sat Feb 10, 2018 10:54 am

Re: GPIO to 5V Relay - 24VAC Solenoid

Mon Feb 19, 2018 6:27 pm

klricks wrote:
Mon Feb 19, 2018 6:11 pm
Learning101 wrote:
Mon Feb 19, 2018 5:55 pm
...
I have been trying to test the resistance with the multimeter, I have the meter set to 200, the lowest setting. But it just shows 1 it does not display a reading.

Does that mean the resistance is too low for my multimeter?
Not possible for resistance to be too low for a reading. Though many cheap meters are not accurate when measuring low resistance, the meter should read 0.xxx. Touch the meter leads together to test.

A '1' displayed usually means infinite resistance or an open circuit OR the scale is set too low.
Yes I must have a cheap meter, when I touch the leads together I do get a reading.

I cannot get any reading off the coil, or the wire itself.

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

Re: GPIO to 5V Relay - 24VAC Solenoid

Mon Feb 19, 2018 7:10 pm

So I have several meters being an ex sparks.

So my calibrated iso-tech IDM303 which auto ranges.
using fused leads 4.35 ohms when shorted together
using un-fused leads 0.24 ohms when shorted together
when leads not shorted reads .OL

my cheap uni-t ut30b meter only has un-fused leads and if I set it on 200 ohm scale reads 00.4 ohms when shorted together, when not shorted together reads 1.

So to measure resistance of coil first short leads and make a note of result.
then connect meter to coil and note reading if its the same as if you had the leads not connected to anything go up one range on your meter 200 > 2000 and keep doing this till you get a reading other than one, if you cant get a reading then it suggests the coil is faulty and is open circuit..
so for a true reading you should subtract the leads reading from you coil reading but in reality the difference will not be much if you have reasonable leads.

so as an example I have some relays with 5v coils
on 200 ohm meter range reading 84.8
on 2000 ohm range 085
20K ohm range 0.08


if you are not sure what you meter is telling you take a picture that shows the reading and setting and post it here.
Please only ask questions in the forum I will not answer questions sent to me directly via PM
Remember we want information.......................no information no help
The use of crystal balls & mind reading is not supported

Learning101
Posts: 20
Joined: Sat Feb 10, 2018 10:54 am

Re: GPIO to 5V Relay - 24VAC Solenoid

Mon Feb 19, 2018 7:20 pm

pcmanbob wrote:
Mon Feb 19, 2018 7:10 pm
So I have several meters being an ex sparks.

So my calibrated iso-tech IDM303 which auto ranges.
using fused leads 4.35 ohms when shorted together
using un-fused leads 0.24 ohms when shorted together
when leads not shorted reads .OL

my cheap uni-t ut30b meter only has un-fused leads and if I set it on 200 ohm scale reads 00.4 ohms when shorted together, when not shorted together reads 1.

So to measure resistance of coil first short leads and make a note of result.
then connect meter to coil and note reading if its the same as if you had the leads not connected to anything go up one range on your meter 200 > 2000 and keep doing this till you get a reading other than one, if you cant get a reading then it suggests the coil is faulty and is open circuit..
so for a true reading you should subtract the leads reading from you coil reading but in reality the difference will not be much if you have reasonable leads.

so as an example I have some relays with 5v coils
on 200 ohm meter range reading 84.8
on 2000 ohm range 085
20K ohm range 0.08


if you are not sure what you meter is telling you take a picture that shows the reading and setting and post it here.
Thanks for your help, I was being stupid the wire a coating.

So at the 200 ohm range The most stable reading I got was 36.0

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

Re: GPIO to 5V Relay - 24VAC Solenoid

Mon Feb 19, 2018 7:30 pm

So your coil reads 36 ohms.

so using V/R = I
6/36 = 0.167A or 167ma.

So 6v may be OK but you wont know if the coil will pull in the armature properly until you test it.
Please only ask questions in the forum I will not answer questions sent to me directly via PM
Remember we want information.......................no information no help
The use of crystal balls & mind reading is not supported

Learning101
Posts: 20
Joined: Sat Feb 10, 2018 10:54 am

Re: GPIO to 5V Relay - 24VAC Solenoid

Mon Feb 19, 2018 8:13 pm

pcmanbob wrote:
Mon Feb 19, 2018 7:30 pm
So your coil reads 36 ohms.

so using V/R = I
6/36 = 0.167A or 167ma.

So 6v may be OK but you wont know if the coil will pull in the armature properly until you test it.
Thanks, I have learned so much trying to figure this out thanks to your guys help,

So in theory, if it worked of 5V 138ma I could power off the same adapter I have for my PI which put out 5V 2.5Amp max (a separate one) and use one of these from eBay?

https://rover.ebay.com/rover/0/0/0?mpre ... 1668810841

What's the worse that could happen if I under power the solenoid? Is it that it won't work efficiently?

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

Re: GPIO to 5V Relay - 24VAC Solenoid

Mon Feb 19, 2018 8:51 pm

Not a good idea to power it off the same supply as you pi its going to put sudden load on the psu and possible reverse voltage spikes back in to the psu as well.

always better to keep pi on its own psu and things like relays and solenoids on there own psu but controlled by the pi.

but its your kit so if you want to try its that's up to you.
Please only ask questions in the forum I will not answer questions sent to me directly via PM
Remember we want information.......................no information no help
The use of crystal balls & mind reading is not supported

Learning101
Posts: 20
Joined: Sat Feb 10, 2018 10:54 am

Re: GPIO to 5V Relay - 24VAC Solenoid

Mon Feb 19, 2018 8:58 pm

pcmanbob wrote:
Mon Feb 19, 2018 8:51 pm
Not a good idea to power it off the same supply as you pi its going to put sudden load on the psu and possible reverse voltage spikes back in to the psu as well.

always better to keep pi on its own psu and things like relays and solenoids on there own psu but controlled by the pi.

but its your kit so if you want to try its that's up to you.
Yes thanks wasn't planning on running it off the PI supply, I have a second PI supply.

Is there any other way that I could control the solenoid rather than using the relay?

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

Re: GPIO to 5V Relay - 24VAC Solenoid

Mon Feb 19, 2018 9:10 pm

If the solenoid is only drawing a small current (under 800ma) you could drive it using a 2n2222 transistor any more than that and you would have to use a mosfet transistor.

I would do some testing with the solenoid and the power supply first to make sure it works ok and check the actual current drawn then you can decide on what you need.
Please only ask questions in the forum I will not answer questions sent to me directly via PM
Remember we want information.......................no information no help
The use of crystal balls & mind reading is not supported

Learning101
Posts: 20
Joined: Sat Feb 10, 2018 10:54 am

Re: GPIO to 5V Relay - 24VAC Solenoid

Sun Feb 25, 2018 3:15 pm

I have an issue I don't understand.

From 4aa batteries the solenoid is powerful enough for the job, but if I try to power using USB using a 5V 1am plug the solenoid is slow and doesn't fully engage,

Why is this when the solenoid works well from 4aa batteries?

Return to “Interfacing (DSI, CSI, I2C, etc.)”

Who is online

Users browsing this forum: No registered users and 5 guests