
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.
| Contact | Common core color | Function to confirm |
|---|---|---|
| Pin 1 | Brown · BN | L+, positive DC supply. Use the sensor’s rated supply range. |
| Pin 3 | Blue · BU | L−, supply return / 0 V. This is not automatically protective earth. |
| Pin 4 | Black · BK | Often the switching output. Other interfaces may assign a different function. |
| Pin 2 | White · WH | May 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
Female · mating faceLooking directly into the sockets
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.
Does an IO-Link or analog sensor use the same pinout?
The common switching-sensor table is not sufficient to wire either interface. Identify the device’s signal type, then match its connection diagram to the receiving channel.
IO-Link: confirm the port class
On IO-Link, Pin 4 is C/Q: communication, or a switching signal when supported and configured in standard I/O mode. Matching the plug does not configure an IO-Link master port.
| Contact | Port Class A | Port Class B |
|---|---|---|
| Pins 1 / 3 | L+ / L−: sensor and electronics supply. | L+ / L−: sensor and electronics supply. |
| Pin 4 | C/Q. | C/Q. |
| Pin 2 | Optional digital I/O or not connected. | 2L+: auxiliary supply positive. |
| Pin 5 | Not connected in the standard assignment. | 2L−: auxiliary supply return. |
Do not pass Class B auxiliary power through to an unknown Class A device’s extra pins. Select the cable and any required isolation of unused contacts from both device and master instructions. Nor should “Class B” be mistaken for a B-coded connector: these are different naming systems.
What about analog sensors or temperature probes?
Stop using the switching-sensor table when the device is a current-loop transmitter, voltage-output sensor or RTD probe. Its conductors may have different functions, even in a familiar M12 housing. Identify the output interface and read the device-specific circuit before choosing the controller channel. A four-wire RTD connection, for example, is not the same circuit as a four-wire switching sensor.
Likewise, a fifth contact is not automatically protective earth or shield. Follow explicit signal, PE and shield designations; do not repurpose a protective conductor as an ordinary signal wire.
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.
- 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.
- 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.
- 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.
- 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.
| What you observe | What to check next |
|---|---|
| No expected power indication | Supply 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 not | Assigned output pin, whether that core exists in the cable, PNP/NPN compatibility, input common and channel configuration. |
| PLC input changes; machine behavior is reversed | NO/NC model or setting, selected complementary output and software inversion. Do not swap the supply wires. |
| Fault appears when the cable moves | After 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
- Phoenix Contact — SAC-4P-M12MS/12,0-652/M12FS, article 1432056. Plug/socket contact-view diagrams and the contact-to-contact cable circuit; basis for the independent conceptual face guide.
- OMRON — E2B Cylindrical Proximity Sensor datasheet, D116-E1. Model table on page 2, PNP circuit on page 12 and M12 cordset mapping on page 19. The B1/B2 comparison is a documented product example, not a customer installation case.
- OMRON — FAQ00379: NPN and PNP transistor outputs. Load-current paths for the two output types.
- IO-Link Community — IO-Link Design Guideline, Version 1.1. Table 3 and the cabling section explain port assignments and Class A/Class B connection limits.