I'm trying to determine if a relay is opened or closed in order to determine if specific code should be executed.
I am checking to see if the state is HIGH or LOW using the digitalRead command. Is it possible to use a regular arduino relay and if so how do I connect it.
I have also considered using a Bosch style automotive relay.
Do you want to know whether a relay controlled by an Arduino output pin is energised or not, or something else ?
If the former then surely you know whether it is energised or not because your code will have commanded it. You can read the state of an output pin if necessary but should not need to if you have a variable holding the current state.
If you want to know the state of a relay that is controlled by an external circuit you have a couple of choices. One is to read the state of the relay input pin but be careful of voltages and polarity. Another is to read the state of the relay output either by using a multi pole relay and using spare contacts to switch an Arduino pin to GND or 5V or possibly to read the state of a changeover relay contact if both ways are not used by the external device. Again, be careful of voltages and polarity.
The relay is controlling something. That is, it's controlled side is letting current flow, or it isn't. Tap into that side of the relay. Connect that to a voltage divider, to drop the voltage to 5V or less. From the middle of the voltage divider, run a wire to a digital pin. Connect all the grounds - the relay, the voltage divider, and the Arduino.
Set the pin mode to INPUT_PULLUP.
When the relay is on, the pin will read HIGH. When it is off, the pin will read LOW.
double pole single throw (dpst) or double pole double throw(dpdt) would be ok.
The input coil is controlled by the external 12v source. One set of output teminals are used by the device powered by the relay. The other set of output terminals is for the Arduino. The most simple connection is one terminal wired to an arduino pin with pinMode INPUT_PULLUP. The other terminal is connected to ground. When the relay is activated, the Arduino input will be pulled LOW.
Yeah, replace what's probably an essential automotive relay that's been approved for automotive use, and replace it with a cheap chinese hobby grade relay because some guy on the internet thinks that's a good idea.
If I were doing that I would use an opto coupler as in reply #9 but if you still want to use a relay, get one like the Bosch thats MADE for automotive use, not a chinese cheapie, here's a simple sketch: