I don't have much experience with this but I'm trying to use my arduino with a 12v three-wire (red, white, black) industrial relay. The relay works (from what I understand) on an open/closed principle. So if I'm right when the relay is closed the 12v is passing through the red to white wires, and the black is ground.
Assuming that last statement is correct, how could I wire this up to my arduino to detect when a relay is closed.
The end result is to detect the relay being tripped, then play a tone.
I do not want to make that assumption. Relays usually have at least four wires. I suppose that three wires could be used, but your assumption seems unlikely to me. More investigation is in order.
That picture seems to show the back of a relay socket, and shows at least five wires (two red, two white, one black).
Those relays do not have any wires of their own. What is seen in the picture is some wires added to the socket.
One normally uses the relay contact to determine whether the relay has switched or not. I gather that you want to use the energizing of the relay coil instead. I could provide a guess at how to do this, but it would be better to know the voltages on the wires, and to know what they are connected to.
By the way, the RH1B-U-DC24 relay has a 24 volt coil. You described a relay with a 12 volt coil. What part number do you really have? It is possible to have a 12 volt coil.
This job would typically be done by using an unused set of contacts on the relay. The relay pictured does not have any unused contacts. Another way would be to use an optoisolator with an appropriate resistor, but you have to know what voltage is present on the coil and what polarity.
The relay you have linke to RH1B-U-DC24 has 2 connections for the coil.
It is a of type SPDT which means it has, in addition, 3 contacts. NO, C, and NC
When the coil is not activated, C and NC are connected together.
When the coil is activated C and NO are connected together. It is across these two terminals that you connect something which has to function if the relay is activated.
*NO - normally open
*NC - Normally closed
*C - common
*activated - electricity is flowing through the coil to operate the contacts.
*SPDT - single pole double throw.
Tourless:
how could I wire this up to my arduino to detect when a relay is closed.
I'm guessing that what is going on here is that the relay is part of an existing piece of equipment and you just want a sensor.
Easiest way would be to attach a voltage divider to the hot end of the relay coil. Use a beefy pair of resistors and add a flyback diode.
I wold expect one side of the relay coil to be grounded, the other side to be hot (12v) when the relay is on. attach (say) a 2M and a 1M resistor in series between the hot end and ground. The voltage at the junction should be 4v when the relay is on. The resistors will drain 4uA, which shouldn't be noticable to the existing machinery. Put a flyback diode between the junction and ground (anode to ground), and connect the junction to an INPUT pin (the resistor to ground acts as a pulldown).
Having said all that - it really might be a good idea to also put an opto-isolator in there.
Maybe 200K---100K rather than 2M---1M might work better.
What PaulMurrayCbr wrote is correct for a 12 volt coil but risks your Arduino if the coil is 24 volts as pictured. Also there is the assumption, likely but still a guess, that one side (which side?) of the coil is grounded.
Wow, thanks everyone. All great input. What I take away from this most is that I have a lot to learn and a number of questions to ask the engineer that install this for me. What I can answer is this...
The lower white wire loops to the populated socket directly to it's left in the pic. The lower red wire is connected to a control panel on the machine. When a product reached a certain point in the machine my relay and the relay to the left trip.
The top two wires (red and white), and the ground (lower black) are open on the other end for my use.
I was told 12v by the electrician but his English is questionable.