PLC Sim Lab
PLC basics

Every way to wire a sensor to a PLC

A sensor has to be wired the right way round for the PLC input to see it. Most of the time that is simple, but on real machines you meet NPN sensors on PNP cards, 2-wire sensors, relays and analog signals. This guide covers every common method, with animations.

5 min read · Updated 2026-10-02

Method 1: PNP sensor to a sinking input

The standard in Europe, India and most of Asia. Brown to +24 V, blue to 0 V, black to the PLC input, and the input group's COM to 0 V. When the sensor detects, it switches +24 V onto the input. See PNP vs NPN for the theory.

Method 2: NPN sensor to a sourcing input

Common on Japanese machines. Brown to +24 V, blue to 0 V, black to the input, and the input group's COM to +24 V. When the sensor detects, it pulls the input down to 0 V, and current flows from COM through the input into the sensor.

Remember: all sensors on one input group must be the same type, because the group shares one COM.

Method 3: NPN sensor on a PNP input, through an interface relay

You have a PNP-only input card but the replacement sensor is NPN (or the other way round). The cleanest fix is a small interface relay (a slim 24 V DC relay on the DIN rail):

The relay contact is a "dry" contact, so the same trick works for any combination: PNP sensor on an NPN card, a 24 V sensor on a 120 V AC input, or a sensor that must be isolated from the PLC. Downsides: a few milliseconds of delay, contact wear, and one more part. For fast counting use a signal converter module instead.

Method 4: PNP sensor on an NPN (sourcing) input

The mirror image: the PNP sensor drives the relay coil (A1 to the black wire, A2 to 0 V), and the relay contact connects the PLC input to 0 V. Switch the animation above to "PNP sensor → NPN input" to see it.

Method 5: 2-wire sensors

A 2-wire DC sensor has no separate supply wires: it is wired in series with the PLC input, exactly like a push button. It powers itself from the small current that flows through the input when it is off. Points to check:

Method 6: NPN sensor with a pull-up resistor

An old trick: put a resistor (e.g. 2.2–4.7 kΩ) from the NPN output to +24 V and wire that point to a sinking input. When the sensor is off, the resistor pulls the input to +24 V (input ON); when it is on, it pulls the point to 0 V (input OFF). It works, but the logic is inverted, the resistor wastes power and gets warm, and the next technician will be confused. Use a relay or the correct sensor instead.

Method 7: Sensors in series (AND) and in parallel (OR)

Best practice: give every sensor its own input and do the AND/OR in the program. Inputs are cheap; troubleshooting time is not.

Method 8: Sensor directly to a relay or contactor (no PLC)

On simple machines a PNP sensor can drive a 24 V relay coil directly (black to A1, A2 to 0 V), and the relay contacts switch a lamp, a valve or a contactor coil. Check the sensor's maximum output current (typically 100–200 mA). Always fit a diode across a DC coil. See contactors.

Method 9: NO, NC and 4-wire sensors

A 4-wire "complementary" sensor has both an NO output (black) and an NC output (white). Wiring both to two inputs lets the program check that they are always opposite: if both are 0 or both are 1, the sensor or its cable is faulty. This is common on important position signals.

Method 10: Analog sensors (4–20 mA, 0–10 V)

Sensors that measure a value, like ultrasonic distance, pressure or temperature, go to an analog input. A 2-wire 4–20 mA transmitter is wired in a loop: +24 V → transmitter → analog input → 0 V. Below about 3.6 mA means a broken wire, which is why 4 mA (not 0) is used as zero.

Method 11: IO-Link

An IO-Link sensor uses the same 3-wire M12 cable, but the black wire becomes a digital communication line to an IO-Link master. You get the switching signal plus the measured value, diagnostics and remote parameter setting.

Method 12: Remote I/O and wireless

Sensors far from the panel connect to a remote I/O block on the machine, which talks to the PLC over one network cable. Where cables cannot go (rotating tables, moving cranes), a wireless sensor sends the signal by radio.

Quick decision table

You havePLC inputDo this
PNP 3-wiresinking (COM to 0 V)wire directly
NPN 3-wiresourcing (COM to +24 V)wire directly
NPN 3-wiresinking onlyinterface relay or converter
PNP 3-wiresourcing onlyinterface relay or converter
2-wire DCeitherin series like a switch; check leakage
4–20 mAanalog inputcurrent loop

Try it yourself. Wire sensors, contactors and a PLC, write ladder logic and press RUN in the free PLC Sim Lab Playground. Nothing to install.

Open the Playground →Guided lessons →