Skip to content
HTM M18 inductive proximity sensor with prewired cable

How to Wire a Proximity Sensor: 2-Wire, 3-Wire, PNP and NPN Diagrams Explained

Most proximity sensors are wired one of three ways: 3-wire DC (PNP or NPN), 2-wire DC, or 2-wire AC. Identify which one you have from the label or part number first; the wiring is different for each, and connecting an AC sensor straight across the supply will destroy it.

Before you start

  • Turn off and lock out power.
  • Confirm the supply voltage on the sensor label (most DC sensors are 10–30 V DC).
  • Confirm the output type: PNP, NPN, 2-wire DC or AC. If unsure, read PNP vs. NPN sensors.
  • Check the load. Sensor outputs typically handle 100–200 mA. That is plenty for a PLC input but not for a solenoid or motor starter; use an interface relay for those.

Wire colors

Wire M12/M8 pin 3-wire DC 2-wire DC
Brown 1 +V + (to supply or load)
Blue 3 0V – (to load or 0V)
Black 4 Output (usually NO) Not used
White 2 Second output on 4-wire models Not used

These follow the IEC 60947-5-2 standard and apply to most brands, but always confirm with the sensor's own diagram. On 2-wire DC sensors with an M12 connector, check which two pins are used, as it varies by manufacturer.

Wiring a 3-wire PNP sensor

  1. Brown to +24 V DC.
  2. Blue to 0V.
  3. Black to the load. The other side of the load goes to 0V.

When the target is present, the sensor connects +24 V to the black wire and the load turns on. To feed a PLC, connect black to the input terminal and tie the input card's common to 0V (a sinking input).

Wiring a 3-wire NPN sensor

  1. Brown to +24 V DC.
  2. Blue to 0V.
  3. Black to the load. The other side of the load goes to +24 V.

When the target is present, the sensor connects the black wire to 0V, completing the circuit. For a PLC, connect black to the input and tie the input common to +24 V (a sourcing input).

In both cases the sensor and the PLC input must share the same 0V reference.

Wiring a 2-wire DC sensor

A 2-wire sensor is wired in series with the load, exactly like a limit switch: brown to +V, blue to the load (or to the PLC input), and the load's other side to 0V. Some 2-wire DC sensors are polarity-independent; others are not, so check the label.

Two-wire sensors have two quirks to plan for:

  • Leakage current when OFF. The sensor draws a small current (often around 1 mA or less) through the load to power itself. Some PLC inputs see this as ON. A bleeder resistor across the input fixes it.
  • Voltage drop when ON. Several volts are lost across the sensor, so the input receives less than the full supply. Make sure that is still above the input's ON threshold.

Wiring a 2-wire AC sensor

AC sensors such as HTM's 20–250 V AC models also wire in series with the load. Never connect an AC sensor directly across line and neutral without a load in series. The output will short and the sensor will fail instantly. The load limits the current.

4-wire sensors

A 4-wire DC sensor adds a white wire that is usually a second output, often the complement (NC when black is NO). Use whichever output gives the logic you want, and insulate the unused one.

Troubleshooting a sensor that won't switch

  1. LED does not light when the target is present: check supply voltage between brown and blue; check the target is within about 80% of rated range and is a material the sensor can see.
  2. LED lights but the PLC input stays off: almost always a PNP/NPN mismatch with the input common, or a missing shared 0V.
  3. Input flickers or stays on: 2-wire leakage current, electrical noise from VFD motor cables run alongside sensor cables, or an unshielded sensor too close to surrounding metal.
  4. Sensor dead after wiring: output shorted to supply, or an AC sensor wired with no load. Most DC sensors have short-circuit protection, AC sensors often do not.

A handheld tester like HTM's S-TER-N sensor tester lets you check a sensor on the bench before blaming the wiring.

Connectors and cables

Quick-disconnect sensors plug into a cordset, which makes replacement a one-minute job. Use a cordset with the same connector and pin count, such as HTM's M8 and M12 cordsets, and see our M12 pinout guide. For machines with many sensors, a distribution block combines them into one home-run cable.

Need a replacement?

Send us the part number from the old sensor and we will match the size, range, output and connector. Call 1-800-724-4209 or request a quote, or browse HTM sensors.

Previous article M12 Connector Pinout and Color Code: 4-Pin, 5-Pin, 8-Pin and Coding Types
Next article Inductive vs. Capacitive Proximity Sensors: How They Work and When to Use Each