Problem with NPN NC proximity sensor

Hello everyone,

I am having a problem connecting a NPN NC proximity sensor to my Arduino.

I connected the sensor as shown:


The Ardunio gets its power from a 9V power source through the Vin pin.

When i measure the voltage between the two yellow marked locations, I get -0,043 V when there is no object in front of the sensor but when the sensor is triggered, I get +8.13 V.

From my understanding, I should get 5V when the sensor is triggered. I do not understand where the 8.13 V come from.

Any help is very much appreciated.

Thank you very much!

It appears the sensor is not an NPN open collector output.

With the Arduino not connected (and the 5V supply disconnected), what two levels do you measure on the sensor output ?


Use your sensor output to drive an NPN/OptoIsolator then connected to a digital input.

Thank you for your reply!

So without the Arduino and the 5 V supply, I get 12,35 V between the black sensor connector and GND when there is an object in front of the sensor. This would indicate it is a PNP instead of a NPN right?

The sensor model is LJ18A3-8-Z/AX

Now I'm really confused.

That makes perfect sense, the sensor is not open collector.

Feed the output to a common emitter configuration (with Vcc connected to Arduino 5v).

Or use an opto coupler.

I am new to those sensors, so I apologize if my questions are dumb.

The common emitter configuration would mean that I am not able to separate the 12v from the sensor from the 5v for the Arduino, correct? Could you explain how I would need to wire the sensor for that configuration?

The reason I chose an NPN NC sensor was because I thought that way I could separate the two voltages without letting the 12 V fry my Arduino. I thought an NPN sensor had the advantage that I would not need an opto coupler. For me it looks like this sensor behaves more like what I would expect from an PNP NO sensor.

That is the right basic idea, but you need an open collector version to protect the Arduino. The best way to completely isolate that sensor and its power supply from the Arduino is an optocoupler, for example:

Capture

R2 is not needed, if you use
pinMode(input_pin, INPUT_PULLUP);
and the grounds shown in the schematic above do not need to be connected together.

Thanks for the explaining, I might just get another sensor that is open collector. It seems like that would make it much simpler.
The reason I got that sensor was because I wanted to keep it as simple as possible without the need to use an opto coupler.
How can you tell wether a sensor is open collector if that isn’t stated explicitly in the description?

If the details are not made perfectly clear on the sales page, do not buy the sensor.

Most sensors of that type come in a variety of configurations, and the sensor data sheet will connect the configuration with a model number (one or more characters in an option field of the model number).

Post the complete model number of your sensor and forum members can check.

You could also try a 18K/10K voltage divider on the output of your LJ18A3-8-Z/AX.
(verify voltage before connecting to Arduino)

A simple and safe interface (with no voltage concerns) for the sensor you have is this one:

Capture

Ground is common to sensor and Arduino. As before, use
pinMode(input_pin, INPUT_PULLUP);

3 Likes

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