Relay as input for arduino

Hi

I need to check a relay with arduino.
The relay is 50 meters away from the microcontroller (No strong RF generators near the cable)
I'm thinking about the schematic attached. What do you think about it?

Thanks in advance.

I think that it should better to use pull-up 10k on input pin and switching it to the GND.
What's about the relay contact, is it dedicated or shared?

Seems reasonable except I'd add 100nF across the input to the opto-coupler to kill any spikes/interference.

You can send 5V to the relay and avoid the extra supply voltage. Since LEDs are current operated
you don't need high voltages to be immune to capacitive interference.

Schematic updated.

Budvar10:
-OK. 1k -> 10k
-It's a dedicated relay from a security IR barrier

MarkT:
-OK. capacitor added
-The 12v power supply is needed to feed the device. Which voltage would you use?

Having a common power supply on both sides of an opto isolator rather defeats the point of using one.

Hi,
Question. Why not feed the coil voltage to the opto coupler and eliminate the relay?

Assuming the relay is out of your control, you could easily replace the opto with a 2n7000. You might change R1 to 4.7k and add a 0.01 uF at the gate of the 2N7000 to ground.

The mosfet would have to be connected to pull the arduino input low and a resistor pull it up (the reverse of what you have).

Also it would be a good idea to twist the traveling wired.

Jon

Grumpy_Mike
How can I protect the uC using only one power source? Do you think it is needed? I've got some capacitors but I haven't got any coil in my box.

tauro0221
The relay is inside the remote device and can't be removed

JohnRob
What is the advantage using the mosfet? I have some 4n35 but no 2n7000.

Thanks friends.

How can I protect the uC using only one power source?

http://www.thebox.myzen.co.uk/Tutorial/Protection.html

jose_francisco:
Schematic updated.
Budvar10:
-OK. 1k -> 10k
-It's a dedicated relay from a security IR barrier

I meant not only change the resistor value but to change it to pull-up from pull-down. It means connect the pin of Arduino to 5V via resistor and switching it via optocoupler to GND (swap the resistor and optocoupler's transistor).
The 10k pull-down is not so good. It is near of internal pull-up resistor value. In case of its accidental switching on it can cause unwanted behaviour on input. Then better value for pull-down is 1k.
Use of pull-up seems to me definitely better solution, plus 10k value means lesser current and still reliable functionality.

Grumpy_Mike
Very useful link. I will implement a solution with the components I have. Thanks

What about this schematic?
Thanks

I would add a 4K7 pull up resistor on that input due to the distance, the internal ones are a bit weak.

Grumpy_mike, is 3k3 too low for a pull up resistor?
I haven't got 4k7 resistors in my box

jose_francisco:
Grumpy_mike, is 3k3 too low for a pull up resistor?
I haven't got 4k7 resistors in my box

Their should be not too much diferance in using a 3K3, it would be fine to use it.