Skip to main content
INDUSTRIAL I/O · SENSORS

NPN vs PNP: What Is the Difference?

NPN and PNP are the two output types of a three-wire DC sensor. A PNP (sourcing) output switches +24 V to the load, so current flows out of the sensor. An NPN (sinking) output switches the load to 0 V, so current flows into the sensor. Each must be wired to an input of the opposite type.

01

What NPN and PNP mean

NPN and PNP are the two types of transistor used to switch the output of a three-wire DC sensor, such as an inductive proximity sensor, a photoelectric sensor or a pressure switch. The letters describe how the transistor is built from N-type and P-type semiconductor layers, but on the factory floor they describe something simpler: which side of the supply the output switches.

A PNP sensor switches the positive side. When it detects a target, its output connects to +24 V and pushes current out into the load, so it is called a sourcing output. An NPN sensor switches the negative side. When it detects a target, its output connects to 0 V and draws current in from the load, so it is called a sinking output.

Both do the same job. The difference only matters when you connect the sensor to a PLC input, an I/O module or a relay, because the input has to complete the circuit from the other side.

02

How each output switches a load

Most DC sensors have three wires, and the colours follow IEC 60947-5-2: brown for +V, blue for 0 V and black for the switched output. A four-wire sensor usually adds a white wire for a second, complementary output. The load (a PLC input, relay coil, lamp or valve) sits between the black wire and one of the supply rails.

  • //
    PNP (sourcing). The load connects between the black output wire and 0 V. When the sensor turns on, current flows from +24 V through the sensor, out of the black wire and through the load to 0 V.
  • //
    NPN (sinking). The load connects between +24 V and the black output wire. When the sensor turns on, current flows from +24 V through the load, into the black wire and through the sensor to 0 V.
  • //
    Normally open or normally closed. Either type can be NO (output on when a target is present) or NC (output off when a target is present). NPN or PNP says which rail is switched; NO or NC says when.
  • //
    Open collector. Many NPN sensors and boards have an open-collector output that only pulls low. To give a clean logic level, it needs a pull-up resistor to the input’s supply voltage.
03

NPN vs PNP compared

The table sums up the practical differences when you are choosing or wiring a sensor.

Feature PNP sensor NPN sensor
Switches Positive side (+V) Negative side (0 V)
Other name Sourcing output Sinking output
Output when on Close to +24 V Close to 0 V
Load connects to Black wire and 0 V +24 V and black wire
Matching input Sinking input (common to 0 V) Sourcing input (common to +24 V)
Where it is common Usually the default in Europe and North America Common on machinery built in Japan and other parts of Asia
Output wire shorted to 0 V Input stays off; output usually trips its short-circuit protection Input turns on, so a damaged cable can give a false signal

The last row is why many machine builders standardise on PNP. A pinched cable that shorts the signal wire to an earthed frame cannot switch a PNP input on, whereas the same fault on an NPN circuit looks exactly like a real detection.

04

Sinking and sourcing inputs

Every sensor output needs an input of the opposite type. A PNP (sourcing) sensor must feed a sinking input, whose common terminal is tied to 0 V, so current flows into the input. An NPN (sinking) sensor must feed a sourcing input, whose common is tied to +24 V, so current flows out of the input and into the sensor. Get this wrong and the circuit never completes: the input simply never turns on, and nothing is damaged.

Confusingly, input cards are often labelled by the sensor they accept rather than by their own direction, so a card marked “PNP input” is a sinking input. Read the wiring diagram rather than the label. Many modern inputs are bidirectional: the optocoupler conducts either way, so the same input accepts NPN or PNP sensors depending on whether you wire its common to 0 V or +24 V. On a programmable logic controller, the choice is normally made per group of inputs that share a common.

IEC 61131-2 sets the rules for 24 V DC digital inputs. It defines input Types 1, 2 and 3 by the voltage and current that must count as on or off, typically on above about 11–15 V and off below about 5 V, so a correctly wired sensor switches cleanly even with some voltage drop along the cable.

FAQ · 01
Is a GPIO pin the same as an industrial digital input?
No. A GPIO pin on a board usually works at 3.3 V or 5 V logic with no isolation, while an industrial digital input expects 24 V signals to IEC 61131-2, is optically isolated and is protected against reverse wiring and surges. A 24 V sensor should go to an isolated input, not straight to a GPIO header.
Read the full FAQ —
05

Connecting NPN and PNP sensors to a computer

An industrial PC reads sensors through isolated digital inputs, either built into the system or added as a card or module. The rules are the same as for a PLC: match the sensor type to the input direction, keep the sensor supply and the input common on the same 0 V reference, and check the input’s voltage range. Our guide to the differences between DIO and GPIO on IIoT gateways explains why isolated DIO is the safer choice for field wiring.

  • //
    Isolated DIO in the system. Several DIN rail PCs in our range list isolated 8DI/8DO digital I/O, so sensors and relays wire straight to the computer.
  • //
    Expansion modules. Our isolated digital I/O MezIO modules list inputs that can be wired for sink or source, NPN or PNP, either individually or in groups.
  • //
    Board-level I/O. PC/104 and PCIe MiniCard digital I/O modules add optoisolated inputs, relay outputs and counter/timers to embedded systems.
  • //
    Mixed sensor types. Where one machine has both NPN and PNP sensors, use bidirectional inputs split into groups, or fit an interface relay or NPN-to-PNP converter on the odd ones out.
06

Quick answers on NPN vs PNP

NPN and PNP sensors: common questions

Is PNP sinking or sourcing?

Sourcing. A PNP output switches +V to the load, so current flows out of the sensor. It pairs with a sinking input. NPN is the opposite: a sinking output that pairs with a sourcing input.

Can I use an NPN sensor with a PNP input?

Not directly. The input card has to complete the circuit from the opposite rail. Rewire a bidirectional input’s common to +24 V, use an interface relay, or fit an NPN-to-PNP converter. Some sensors are also sold with a switchable output.

How do I tell if a sensor is NPN or PNP?

Check the label, then measure. Datasheets and the sensor body usually say. Otherwise, power the sensor, trigger it and measure the black wire: close to +24 V against blue means PNP, close to 0 V against brown means NPN.

Which is better, NPN or PNP?

Neither, but PNP is the more common default. PNP is usual in Europe and North America and fails safer if the signal wire shorts to earth. NPN suits machines and controllers built around sourcing inputs, which is common in Asia. Match whatever the controller expects.

Is an NPN sensor the same as an NPN transistor?

It contains one. An NPN transistor is a bipolar junction transistor with a P-type base between two N-type layers. An NPN sensor simply uses one, or a MOSFET that behaves the same way, as its output switch.

We fit and configure isolated digital I/O in our industrial computers as standard, and we check the input direction against your sensor list before the system ships.