Connecting a light barrier (NPN or PNP) to an Arduino

Hello,
I need to connect a light barrier (NPN or PNP) to an Arduino.
I am powering the barrier with 24V.
I need to be able to send the information that an object has been detected to my Arduino.
How can I do this safely?

Some information obtained from the manufacturer:


Merci d'avance

The safest option is to use an optocoupler.

2 Likes

Thanks for your response.
Seems to be a good option.
Need to test.

Thanks to you to take the time to write your response

What is the maximum / minimum current for the NPN or PNP output?

I'd first try wiring a led, with a 4.7k series resistor between, 24v and NPN. It is not clear from the document if the led will be on or off during a detection but that would be the first thing you would discover with this experiment.
The optocoupler is a good idea so you don't have to share either of the 24v supply power rails with the Arduino.

Is your npn output an open collector output?
In that case you can put the load resistor on the 5V rail (instead of the 12 V rail and read the signal from the grey cable).