Hooking up NPN inductive sensor powered by 12V battery

I wish to run a 10-36V NPN inductive sensor on my Arduino using a 12V battery to power both the Arduino and sensor. I have been researching past posts on the topic and from what I have read I think I have made a schematic of the correct set up, but I would appreciate getting confirmation from someone more experienced than me.

I am attaching the schematic to this post. I used fritzing to create the circuit, even though I realized it is an unpopular choice. I did my best to make it as clear as possible.

My question regarding this is set up are:

  1. What is the exact function of the pull-up resistor connecting to the signal cable and how do I know 10k is the appropriate resistance?

  2. How can I ensure that my signal wire (black) will not deliver a voltage capable of damaging my Arduino?

Thank you for any possible input :slight_smile:

  1. In general, a pullup makes sure that a pin reads high when a sensor is not explicitly making it low. That might sound odd, but just because the sensor isn't low, there's no reason to a expect it to be high.

  2. You should check the datasheet of your actual sensor to see if its output is ok for the Arduino. (You didn't say what model, not all are 5V, so that may be 3V3.) If the output depends on the input voltage, then you'll need to condition the (say) 12V down to 5V or 3V3 with a simple divider.

Lucaru1997:
I wish to run a 10-36V NPN inductive sensor on my Arduino using a 12V battery to power both the Arduino and sensor. I have been researching past posts on the topic and from what I have read I think I have made a schematic of the correct set up, but I would appreciate getting confirmation from someone more experienced than me.

I am attaching the schematic to this post. I used fritzing to create the circuit, even though I realized it is an unpopular choice. I did my best to make it as clear as possible.

My question regarding this is set up are:

  1. What is the exact function of the pull-up resistor connecting to the signal cable and how do I know 10k is the appropriate resistance?

To pull up the line voltage to 5V from ground if the NPN open-collector output is inactive. For long
cable runs use a lower resistor to reduce noise pickup, say 4k7 or 2k2 or 1k for v. long. Most
inductive proximity sensors are open-collector output, but note that some are PNP which are harder
to interface to.

  1. How can I ensure that my signal wire (black) will not deliver a voltage capable of damaging my Arduino?

Use a series connected 10k resistor to the pin to limit any current perhaps.

Thank you for any possible input :slight_smile:

Some of those NPN inductive sensors have an internal pullup.

What's the part# or link to your sensor?

Im gonna use an uno for the project, and the npn sensor I will use is this one:

part #: LJ18A3-8-Z/BX

I am unsure whether it has an internal pullup, and I do not know whether the output voltage is dependent on input.

Also where could I find proper examples on dividing the voltage from 12v to 5v for the output?

This is my first project of the sort so I appreciate any help that could guide me to the right set-up!

I think it has a built-in 10K pullup (found this image on the web)

Are the wire colors as in the diagram? If so, with the +12V connected to Marron (or brown) and battery -ve (GND) connected to blue, measure the voltage from the black to blue wire. Should get 12V (battery voltage) when switched off and near 0V when switched on.

If the voltage switches from about 12V to about 0V, then try connecting a 6.8K resistor from the black to the blue wire. Re-test the voltages and see if you’re getting from about 5V to 0V. If so, then it’s ready to connect to your 5V Arduino board. Make sure the resistor is securely in place.