# proximity switch

I've got a (I think it's magnetic) proximity switch here(Balluff BES00NA) I want to use to detect when I'm against a steel plate. It gives me a reading of 18 volts on it's output pin when it's close to the plate. It is powered by two 9volt batteries in series. I tried to wire it's output pin to a grounded digital pin like a switch) but I'm just reading zero on the digital input.

Any tips on what I need to do to get a usable input here?

You should never connect any voltage source greater than 5v or less than 0v directly to an Arduino pin. You need to use a voltage divider or similar on the output pin to reduce that 18v to around 5v. Something like:

27k resistor from sensor output to Arduino input pin 10k resistor from Arduino input pin to ground

And of course you need to connect the ground (negative) side of the sensor to Arduino ground.

[EDIT: I think it may be similar to this one http://www.nuovaelva.it/files/docs/Balluff/en/datenblaetter/BES%20516-324-E4-C-S4-00,3.pdf]

Before jumping to any conclusions about the output of the proximity sensor do some measurements first.
Connect it up to the power and then measure the voltage you get on the output with a meter both with and without the plate.

If this always reads zero, then connect the output through a 10K resistor wired up to +5V.
Again measure the output. You might find that it then goes between zero and +5V. Sensors like this are often fitted with a reed relay and it is an actual switch.
If this is the case then it can simply be connected to an arduino input and if you enable the internal pull up resistors you should be able to read it.

Grumpy_Mike: Before jumping to any conclusions about the output of the proximity sensor do some measurements first. Connect it up to the power and then measure the voltage you get on the output with a meter both with and without the plate.

It sounds to me that he's done that already - he reads 18v output when the sensor is near the plate - although he didn't state in his post what the reading is with the sensor away from the plate.

Grumpy_Mike: Sensors like this are often fitted with a reed relay and it is an actual switch.

The data sheet suggests it is an open-collector PNP transistor - which would account for the +18v reading on the output. The sensor itself is short circuit protected, but with a rated output of 200mA, it may have damaged the Arduino pin it was connected to.

Thanks for the help guys.

dc42: You should never connect any voltage source greater than 5v or less than 0v directly to an Arduino pin. You need to use a voltage divider or similar on the output pin to reduce that 18v to around 5v. Something like:

27k resistor from sensor output to Arduino input pin 10k resistor from Arduino input pin to ground

And of course you need to connect the ground (negative) side of the sensor to Arduino ground.

[EDIT: I think it may be similar to this one http://www.nuovaelva.it/files/docs/Balluff/en/datenblaetter/BES%20516-324-E4-C-S4-00,3.pdf]

This got it working. thanks a ton!