NPN Proximity Sensor Voltage issue

Hello .. I'm having a problem with my NPN Proximity Sensors and voltage. The sensors use 6 to 30 volts. I'm able to get them to work with using the 5v from the Arduino Uno. I'm using digital input 2 for the input signal.

But I know when I install them that due to the length of wire they are not going to work due to voltage drop. So I want to use 9 volts to power them.

Now here's the problem.. The sensors are normal open. But when I test them with my meter i'm getting 9v while open. and when I close the sensor I get ground ..

My concern is that when the sensor is open the 9v is going to fry the board..

Don't ask me why I'm getting a voltage return.. It should be open with no return at all and when its closed a ground should just return.

Can I just use the internal PULL_UP resistor to knock down the 9v to 5v or do I need to add one??

I watched a youtube video were he just used the internal.. But I don't want to fry the board just to test..

any help would be much appreciated..

Post a link to the sensor product page or data sheet.

To use the internal pullup resistor on the Arduino, you MUST have an open collector NPN output.

here's the link to ebay were I purchased them..

spec sheet

The rather unhelpful spec sheet is not clear about whether the output is open collector.

If you measure voltage at any time on the output, then it probably is not open collector, and you cannot connect it directly to an Arduino input.

Instead, use a voltage divider. Two resistors in series, say 5K Ohms, from output to ground will bring 9V down to about 4.5V at the junction, which is safe for the input to a 5V Arduino.

Probably a dumb Q, but which 2 wires are you measuring across? If you put a 220 Ohm resistor between blue and black, what kind of voltage do you see across the resistor when switching? Between brown and black?

Voltage divider, or a diode (pointing away from the Arduino) and pull-up resistor (between pin and +5, or your internal pull-up), then you're independent of the voltage on the signal line, as long as it's >5V you're good.

Hey Outsider.. What I did was I attached the +5v to Brown and the -5v to Blue. Black is the return. So with my meter attached to the +5v I attached my Negative probe to black and then activated the sensor.. The meter reads nothing deactivated and 5v activated.. Which was great..

But .. When I would attach the probe to my -5v negative Blue and probe my Black it reads +5v while deactivated and nothing when activated. So if I'm getting +5v while its supposed to be in an open state something's wrong.. It could be me.. I'm willing to admit that.. I could be doing something wrong.

I can see that the data sheet isn't helpful at all.. Unfortunately it was all I could find..

I'd like to thank you all for your reply's.. I just wasn't sure the internal resistor would work.. The more I was reading online people recommended using a resistor or voltage divider. I'm going to test the voltage with a resistor seeing how I have a few different ones I can try and see what happens. Ill let you know how it works out..

Thanks again..

If you indeed have -5V and +5V you will read 10V between them, and you will also have a third power wire: GND or 0V. That seems to be the case for you indeed.

But before you mentioned you measure 9V on the sensor output, and now you measure 5V. How's that?

Looking at that video, if you have it wired as he does (But using 5V instead of 9V) then it appears to be working the same as the one in the video.

When the sensor is not active, you should be getting 5V between the black wire and GND. Because of the pull up resistor. When the sensor is active it grounds the signal wire so you should be getting 0V between the black wire and GND.

Did you try to connect a 9V battery to the Brown (+ve) and Blue (-ve) wires, and measure the voltage between the black wire and -ve terminal for both scenarios?

Wait! Put the resistor between black and brown, I had PNP in my 'ol head. sorry.

Hey Wvmarle.. Sorry for any confusion .. I'm using the 5v from the Arduino for testing purposes.. But I will be using 9v when I install them.

Hope you realise that this does make a big difference in how to wire it all up... at 5V no worries about overloading the pin.

Hey Rickerman.. When I tested the sensor with my meter the voltage was directly from the power supply. They were not attached to the Arduino and had no pull_up resistor. I attached the power to Brown. The ground to blue. and black is my signal.

with it not activated the black and blue says 5v..

When activated the black and blue says zero because it zeros out the meter because the black wire signal turns to ground.

When activated I switch the lead on my meter from blue to brown. Now I get a 5v reading on my meter.

Which means for some reason my black signal wire is switching from +5 un-active to ground active.

which would be fine if I could get away with 5v.. But 5v is already under powering them. and these sensors will be at the end of a 25ft wire. The voltage drop will make then not work at all with 5v.

I hope this explains it a little better.. I do appreciate all the help on this.. Thx

Sounds like there's a pull-up resistor in place on the output.
That's a pity, as it means you're getting the 9V to your pin.
When you have a sufficiently large pull-up resistor value (and I may assume you don't know the actual value!) you could rely on the clamping diodes. A 10k between the pin and the sensor output should be safe: you'd have only 0.35 mA (9V - 5.5 means 3.5V over the resistor).
Alternatively, use the diode + pull-up resistor method.