PNP or NPN if both are possible for a sensor-model?

As you know I am playing with weird sensors for all sorts of tihngs. I think I have asked this question before but cannot find the answer.

If I have two models of the same sensor with either PNP or NPN, which one of them would you choose.

The PNP circuitry has more resistors, but might have other benefits.

Whats you rule of thumb here?

Just use a module that supports both - problem solved :wink:

Hmm maybe I am not clear enough. Both models work fine, and no issues. But I am looking for a general rule of thumb in terms of power consumption, flexibility for multiple voltages and the like…

You can push a fixed voltage, or you can drain multiple… you choose.

I presume you’re contrasting two bipolar transistor circuits here? is that the case you’re trying to understand how a choice is made between some NPN bipolar transistors and some comparable PNP?

@ KorporalKernel - Thanks for finding this old question and re-iterating it. :slight_smile:

Looking at for example [url][/url] I find two editions of the same sensor, and I am connecting it to a GPIO port on using a little circuit in front.

I am using the attached drawing as my connection guide - but I have not been able to conclude which one of the sensor editions are best suited to connect to for example Cerberus or Spider ports.

1 Like

@ Justin your module is useless for sensing whether there is an object in the path of something.


The module is apparently switchable between PNP and NPN mode, so it doesn’t matter.

The two diagrams are really either giving you a voltage dictated by the input voltage ratio’ed down via the resistor divider, or it’s pulled up to the correct voltage (shown as 3v3). I personally would prefer the pullup scenario as I’d hate to overload my micro if the input voltage went out of spec or something…

Indeed Mr Pound, said module does not sense life the universe or anything but 1 or 0…


You can wire either one of the above sensors to said mythical module in NPN or PNP with upto 24v without cooking micro…

So there :stuck_out_tongue:


For this reason on digital or analog inputs, I include a 3.6V or 5.2V zener with a 100 ohm series resistor to limit the current and voltage depending on the max input voltage. This handles +24V quite well for my analog 4-20mA inputs and a similar setup protects the digital inputs. Of course I also have other circuits to drop the voltage to a suitable level but the zener is the last line of defense. :slight_smile:


Which means (in case their is specific editions of the sensor) that you would prefer the NPN edition wired in the pull-up configuration - the leftmost on my drawing…

This module could come in handy for connecting more exotic stuff… Can I have a look at the schematics?


@ Justin - Beautiful! Thanks! :smiley:

To make it clearer than mud…

1 Like