Zhejiang Xinsenzheng Automation Co., Ltd.

Industrial Sensor Manufacturer OEM & Application Support Factory-direct Supply
Generic illustration of an industrial sensor with a mated M12 cable connector

M12 Sensor Connector Pinout: 3-Wire and 4-Wire Wiring Explained

A common A-coded DC sensor uses Pin 1 for positive supply, Pin 3 for 0 V and Pin 4 for its output. But connector view, model suffix and extra-pin functions can change how you wire it. Match the numbered contacts to the actual sensor and cordset diagrams—not just the wire colors.

Which pins does a typical 3-wire M12 sensor use?

Many A-coded DC switching sensors use Pin 1 for positive supply, Pin 3 for the supply return and Pin 4 for the output. This is a useful starting point, not permission to connect an unidentified sensor. Read the connection diagram for the complete part number, including its output and connector suffixes.

Common 4-position A-coded cordset mapping and DC switching-sensor functions. The sensor diagram takes priority.
ContactCommon core colorFunction to confirm
Pin 1Brown · BNL+, positive DC supply. Use the sensor’s rated supply range.
Pin 3Blue · BUL−, supply return / 0 V. This is not automatically protective earth.
Pin 4Black · BKOften the switching output. Other interfaces may assign a different function.
Pin 2White · WHMay be unused, an output, a teach input or another model-specific connection.

The colors describe a common cordset convention. A field-wired connector, adapter, junction box or replacement cable can change the mapping. Follow the contact number through the actual cable drawing to the controller terminal; do not identify an electrical function from color alone.

Why can a 3-wire sensor have a 4-pin connector?

These counts describe different things. A 3-wire DC sensor normally needs two supply connections and one signal connection. A 4-pin connector has four contact positions. A 4-core cable has four conductors. The sensor may use only three of those contacts, and the spare conductor does not become a second output simply because it exists.

This guide concerns common A-coded sensor connections. Do not apply the table unchanged to two-wire loop-powered devices, RTD probes, Ethernet, fieldbus or M12 power connectors. “M12” alone identifies neither the operating voltage nor the signal interface.

How do you read male and female M12 pin views?

First identify which face the drawing shows. A mating-face view looks directly into the contacts that meet the other connector. A rear or wiring-side view looks from the termination side. Male and female mating faces also appear mirrored when their key features are placed in the same orientation.

Male · mating faceLooking directly at the pins

Four-position A-coded male mating face, key at the bottom Pin 4 upper left, Pin 3 upper right, Pin 1 lower left and Pin 2 lower right. The key reference is between Pins 1 and 2. 4312 Key reference at 6 o’clock

Female · mating faceLooking directly into the sockets

Four-position A-coded female mating face, key at the bottom Pin 3 upper left, Pin 4 upper right, Pin 2 lower left and Pin 1 lower right. The key reference is between Pins 2 and 1. 3421 Key reference at 6 o’clock
Conceptual contact-location guide for a 4-position A-coded interface, with both key references oriented downward. Not a dimensional drawing or a diagram for other codings. Pin 1 mates with Pin 1; the different left/right positions do not mean the cable should be cross-wired.

In the orientation above, the male face has Pins 4–3 across the top and 1–2 across the bottom; the female face has 3–4 above and 2–1 below. Rotating a connector changes where a pin appears, not its number. Use the molded numbers and the manufacturer’s identified view to resolve the position.

What if the drawing says “wiring side”?

Do not copy its left/right arrangement onto the exposed mating face. For a field-attachable connector, follow its numbered terminals and assembly instructions. Also identify male or female by the contacts—pins or sockets—not by the coupling nut, which can be misleading.

What changes when the sensor has four wires?

A fourth conductor allows an additional connection, but its function is defined by the sensor. It might carry a second output, a complementary output, a teach input or an analog signal. “4-wire” does not tell you which of these you have.

On a documented complementary-output model, one connection may provide normally open (NO) behavior and another normally closed (NC) behavior. On a teach-input model, that same extra connection may instead change a setting when driven. Connecting it as an output would be a different electrical operation.

Leave a documented unused conductor individually insulated. Do not join Pins 2 and 4, connect an unknown pin to supply, or assume that changing pins will select NO/NC on every sensor.

Why a 3-wire replacement can still need Pin 2

Documented model comparison: OMRON’s E2B datasheet lists E2B-M12KS04-M1-B1 as PNP NO and E2B-M12KS04-M1-B2 as PNP NC. For these M12 connector versions, the PNP circuit drawing assigns the NO output to Pin 4 and the NC output to Pin 2; the supply remains on Pins 1 and 3.

These are separate model variants, not a promise that either model offers both outputs. A cordset carrying only Pins 1, 3 and 4 would therefore miss the specified output of the B2 variant—even though the connector fits.

Practical consequence: compare the complete replacement part number and its output contact before reusing a cable. Changing NO to NC can also change the required conductor, not just the PLC logic.

A prewired sensor drawing may label its output lead “black,” while a mating cordset maps Pin 2 to a white core. Treat the sensor’s lead colors and the separately supplied cordset’s contact-to-color map as distinct pieces of information.

Can PNP and NPN sensors use the same M12 cable?

A passive cordset can serve either output type when its contact mapping and ratings match both devices. The cable does not convert PNP into NPN. The controller must still provide the correct input circuit and common connection.

  • PNP output: supplies current from the positive side to the load or PLC input. The matching input path normally returns to 0 V.
  • NPN output: sinks current toward 0 V. The matching input path normally receives current from the positive supply side.

Follow the exact PLC input-group diagram. Its common may be shared, isolated or configurable; a terminal labeled COM is not a universal instruction to connect 0 V. Check the permitted input voltage/current and the sensor’s output rating as well as its polarity.

NO/NC describes behavior, not current direction

For a conventional proximity switch in normal powered operation, NO generally means the output becomes active when the target is detected; NC gives the opposite detection logic. PNP/NPN describes how the active output drives current. Record both properties, then verify the actual output contact. Reversing the supply is not a way to change either property.

What must a replacement cordset match?

A replacement must provide the right physical fit and preserve the required electrical paths. The words “M12 sensor cable” are not a complete specification.

  1. Coding, contacts and endsMatch the coding, mating interface, contact arrangement and gender at each end. Check that a right-angle exit clears the bracket and does not strain the cable. Do not force connectors together or assume different contact counts are interchangeable.
  2. Every required conductorCheck the connection map, not just the connector face. A four-position housing can be supplied with fewer connected cores. A splitter or adapter may remap contacts, and a cordset with LEDs or electronics is not equivalent to a plain passive cable.
  3. Electrical and cable ratingsConfirm voltage, current, conductor size, length and any required shield arrangement. A high connector voltage rating does not raise the sensor’s allowable supply voltage. For moving installations, use the specified flex or torsion capability rather than assuming every jacket is suitable.
  4. The installed sealCheck the compatible mating parts, gasket condition, cable entry and manufacturer-specified tightening method. An IP rating depends on the stated assembled condition; it does not describe an open or loosely connected interface.

A useful replacement record states the sensor model, cordset model, contact-to-core map, cable length, output type and receiving input module. This makes the next replacement repeatable without relying on a photograph of wire colors.

How can you verify the wiring before returning to service?

Verify the chain from device function → contact number → cable conductor → controller terminal. The connector-face diagram answers only one part of that chain.

Work within the machine’s electrical safety procedure. Isolate the circuit and prevent unintended movement before changing connections. Do not use this general guide to modify a safety circuit or bypass an interlock. Energized measurements belong to authorized personnel using the appropriate procedure and test equipment.

Check documents and the isolated cable first

Compare the actual sensor label with the connection diagram, including the suffix. Identify the mating or wiring view, the supply polarity, every used output/input pin and the PLC common. If those assignments conflict, resolve the conflict before energizing.

For an unpowered passive cable disconnected at both ends, a suitable continuity test can confirm which conductor reaches each numbered contact and whether unwanted connections exist between conductors. Include any adapter separately. Do not continuity-test through powered equipment, sensor electronics or a cable containing electronics as though it were plain wire.

Check the complete signal path during controlled commissioning

After restoring connections correctly, use the manufacturer’s commissioning procedure. Verify the supply at the device and the expected output behavior, then compare the sensor indication with the physical PLC input and the program’s interpreted state. Where access requires live probing, use a suitable test adapter and the approved electrical procedure—not loose probes that can bridge adjacent contacts.

Use the observation to choose the next check; none of these symptoms proves a single cause.
What you observeWhat to check next
No expected power indicationSupply presence and polarity, the actual supply contacts, cable continuity and connector seating. First confirm that this model has a separate power indicator.
Sensor changes state; PLC input does notAssigned output pin, whether that core exists in the cable, PNP/NPN compatibility, input common and channel configuration.
PLC input changes; machine behavior is reversedNO/NC model or setting, selected complementary output and software inversion. Do not swap the supply wires.
Fault appears when the cable movesAfter isolation, inspect strain relief, contact retention, cable damage and suitability for the actual motion. Reseat or replace only through the approved procedure.

For the pinout check, the documented connection and the observed controller response must agree in both target-present and target-absent states. Record the final part numbers and terminal mapping, then complete the machine’s required recommissioning checks. A lit sensor LED or a connector that screws together is not enough.

Sources and method references

Select the fields to be shown. Others will be hidden. Drag and drop to rearrange the order.
  • Image
  • SKU
  • Rating
  • Price
  • Stock
  • Availability
  • Add to cart
  • Description
  • Content
  • Weight
  • Dimensions
  • Additional information
Click outside to hide the comparison bar
Compare