Connection to Photoelectric sensor

Hello, How to connect below photoelectric sensor to arduino mega 2560 to sense relay high or low

https://robu.in/product/switch-infrared-beam-photoelectric-sensor-photocell-e3jk-5dm1-dc12-24v-detecting-distance-5m/?gclid=Cj0KCQjw-4SLBhCVARIsACrhWLVee3Yjikr35m1nTJ_JOIlN1EqR3ZgbfOa1IrqDezaed0YDfWqEFmcaAumKEALw_wcB

There is not much information there.

This implies an input voltage of 12 to 24 volts:

Photocell E3JK-5DM1 DC12-24V

This could imply 2 power wires (+Xvolts and GND) and three relay wires Common, Normally Open and Normally closed :

Output mode: AC and DC universal five-wire relay output, normally open + normally closed

This could imply 2 power wires (+Xvolts and GND) and three relay wires Common, Normally Open and Normally closed : This is right. So how to connect

Data sheet http://www.farnell.com/datasheets/1634350.pdf

From this, if this matches the model which you are referring to, it appears that it can be mains powered (blue and brown wires).
Check very carefully that this is your model before connecting mains to it. If you have a 12v DC source, that would be safer.

The white wire is connected to the Mega's GND
The black wire is connected to a digital input pin (you choose this - say pin 3 )
The gray wire is not connected.

In your sketch you enable the built-in pull up resistor example: pinMode( 3, INPUT_PULLUP )

Thank You

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.