Industrial sensor wiring guide
M12 Sensor Connector Pinout: Read the View Before You Wire
For a common 3-wire A-coded DC switching sensor, Pin 1 is normally L+ (brown), Pin 3 is L- (blue), and Pin 4 is the output (black). That is a useful starting pattern, not permission to skip the device diagram. Connector coding, contact count, male/female orientation, output type and device profile must all match before power-up.
Quick answer
The familiar 1-3-4 pattern is a common sensor profile, not a universal M12 rule.
Use the pattern below to orient yourself, then verify every function against the exact sensor, cordset, master and PLC documentation.
Common 3-wire A-coded switch
Pin 1 / brown is commonly L+, Pin 3 / blue is commonly L-, and Pin 4 / black is commonly the switching output. Pin 2 is unused by that device.
Typical use: inductive, capacitive or photoelectric 24 V DC switching sensor.Pin 2 does not have one fixed job
On a 4-wire device, Pin 2 / white may be a second output, complementary output or another device-defined channel. In IO-Link, C/Q is on Pin 4; Pin 2 has a different role.
Wire count describes available conductors, not the signal technology.The exact wiring diagram wins
Male and female mating-side views are mirrored. A wiring-side drawing may reverse them again. Read the view caption, connector coding and pin numbers before trusting color or memory.
Never energize a guessed pinout.The first wiring decision
Confirm whether the drawing shows the mating side or the wiring side.
A 4-position A-coded M12 plug and socket carry matching contact numbers, but their mating faces appear mirrored. The keyway, viewing direction and male/female label are part of the pinout.
The most expensive mistake can happen before you read the function table.
If you copy the physical position from a plug drawing onto a socket drawing, Pin 1 and Pin 2 can trade sides, and Pin 3 and Pin 4 can trade sides. Follow the printed pin numbers, not left-versus-right memory.
4-pin A-coded plug
Viewed directly into the plug mating side, with the keyway at the top.
4-pin A-coded socket
Viewed directly into the socket mating side, with the keyway at the top.
Simplified identification diagrams based on a 4-position A-coded plug-to-socket cordset drawing. They are not dimensional drawings. Always use the view and numbering printed in the selected connector or device documentation.
Common 3-wire arrangement
For a typical DC switching sensor, power uses Pins 1 and 3; the signal uses Pin 4.
This is the arrangement most maintenance teams expect on an A-coded 4-pin proximity or photoelectric sensor. It is also the arrangement shown by many product families that offer an M12 connector version alongside brown, blue and black flying leads.
Common example, viewed by pin number
- Pin 1, brown (BN): L+ supply, commonly +24 V DC in automation systems.
- Pin 3, blue (BU): L- or 0 V return.
- Pin 4, black (BK): primary switching output.
- Pin 2, white (WH): physically available in a 4-position interface but not used by this 3-wire device.
What an extra conductor really means
A 4-wire or 5-wire cable does not tell you what the extra pins do.
The connector provides positions. The device manufacturer assigns the electrical functions. Use these common profiles to recognize possibilities, then read the exact product diagram.
Complementary switching
Pin 4 may provide NO and Pin 2 may provide NC, or the assignment may be reversed. Both outputs normally share the same supply and target state.
Useful for selecting the logic needed by a controller, not a substitute for a safety-rated architecture.Two independent outputs
A distance or process sensor may use Pins 4 and 2 for separate thresholds, alarms or switching channels.
Confirm whether each output is PNP, NPN, push-pull or device-specific.IO-Link communication
For IO-Link, Pin 4 is C/Q. Pin 2 is not an alternate C/Q pin; it may be unused, a digital channel or extra power depending on the port class and device.
Master port class and device port class must be checked together.Analog measurement
An analog sensor may use the available pins for voltage, current, return, teach input or alarm output in a manufacturer-defined arrangement.
Do not assume that every 0-10 V or 4-20 mA signal is on Pin 4.Interactive pinout decoder
Select the electrical profile before assigning meaning to the pins.
This tool separates common sensor arrangements that are often mixed together. It shows a planning map only; the selected device and port documentation remains the final authority.
What are you wiring?
Planning result
Common 3-wire A-coded switching sensor
This familiar layout is widely used for DC proximity and photoelectric switching sensors with one output.
Verify supply range, PNP/NPN, NO/NC and plug/socket view on the exact model.
Mechanical coding
A, B, D and X coding prevent incompatible connector families from mating.
The M12 x 1 screw-locking format describes the mechanical interface; it does not identify the voltage or signal. The molded key shape identifies a connector family and blocks many wrong connections. Coding narrows the intended application, but it does not define every signal function on every device.
An A-coded 4-pin sensor cordset, a D-coded industrial Ethernet cordset and an X-coded high-speed Ethernet cordset are not interchangeable even though all are described as M12 connectors.
| Coding family | Typical industrial role | What it does not guarantee | Order check |
|---|---|---|---|
| A | General sensor/actuator signals, DC I/O and many IO-Link devices. | It does not guarantee a 1-3-4 switching pinout, voltage, output polarity or Pin 2/5 function. | Confirm position count and the device wiring diagram. |
| B | Selected fieldbus and signal applications, including products for PROFIBUS. | It is not a general replacement for an A-coded sensor connector. | Match the fieldbus product and shield/termination requirements. |
| D | 4-contact industrial Ethernet applications, commonly up to 100 Mbit/s. | It does not carry the common A-coded sensor-actuator pin profile. | Confirm protocol, cable category, shielding and network device. |
| X | High-speed industrial Ethernet with four shielded data pairs, up to 10 Gbit/s in suitable systems. | It is not required merely because a sensor has diagnostics or IO-Link. | Confirm network speed, pair assignment and rated cable assembly. |
| L / S / K | Examples of M12 power connector families for different power applications. | They are not signal-cable alternatives and are not mutually interchangeable. | Match voltage, current, coding and protective-conductor arrangement. |
Wire color without guesswork
Remember three separate layers: core color, connector pin number and device function.
A common 4-core A-coded cordset uses brown, white, blue and black conductors. That color-to-contact sequence is useful for panel work, but the signal function still comes from the connected device.
A fifth conductor is especially dangerous to generalize. Depending on the selected cable it may be gray or green-yellow, and depending on the device it may be an extra signal, extra supply, protective/functional connection or unused contact.
| Pin | Common 4-core A-coded cordset color | Common 3-wire switch example | What must be verified |
|---|---|---|---|
| 1 | Brown (BN) | L+ supply | Actual voltage range, polarity and any port-class definition. |
| 2 | White (WH) | Unused by this device | Second output, complementary output, I/Q, extra supply or other device-defined function. |
| 3 | Blue (BU) | L- / 0 V | Supply return, signal return and isolation arrangement. |
| 4 | Black (BK) | Primary switching output | PNP, NPN, push-pull, analog or IO-Link C/Q function. |
| 5 | Not part of a 4-core cordset; color varies in 5-core products | Not present | Do not assume shield or FE. Check cable construction and device assignment separately. |
Output topology
PNP and NPN can use the same pins while driving the PLC in opposite directions.
For the common 3-wire profile, both types may use Pin 1 for supply, Pin 3 for return and Pin 4 for output. The difference is the internal transistor and the direction of load current.
The sensor provides positive voltage to the load.
When active, the output sources current toward the PLC input. The input circuit returns to 0 V.
The sensor pulls the load toward 0 V.
When active, the output sinks current from the PLC input through the sensor to the 0 V return.
NO/NC and PNP/NPN answer different questions.
PNP/NPN describes output current direction. NO/NC describes the output state relative to the sensing condition. Confirm both, plus PLC common and desired machine logic.
IO-Link and analog devices
Do not apply a switching-sensor memory rule to communication or measurement ports.
IO-Link has a defined C/Q contact, while analog sensors can use manufacturer-specific arrangements. Treat these as separate electrical profiles.
Sensor/electronics supply with C/Q
- Pin 1: L+ / US+, commonly brown.
- Pin 3: L- / US-, commonly blue.
- Pin 4: C/Q for SIO switching or IO-Link communication, commonly black.
- Pin 2: may be not connected, DI or DO depending on the master/device design.
- Pin 5: not connected for the defined Class A port profile.
Separate additional actuator power
- Pins 1 and 3: US+ and US- for device electronics.
- Pin 4: C/Q communication.
- Pin 2: 2L+ / UA+ for the additional supply.
- Pin 5: 2L- / UA- for the additional supply return.
- Cable: Class B to Class B normally requires all five conductors and the correct port arrangement.
Pin 4 is the IO-Link C/Q line
Do not move C/Q to Pin 2 because a 4-wire switching sensor used white as a second output. IO-Link communication is assigned to Pin 4.
Check master mode: IO-Link, digital input or digital output.Analog pinouts are device-specific
A 0-10 V, 4-20 mA, teach input, alarm output or isolated return can appear on different contacts in different products.
Use the exact terminal diagram and input specification.Shielding is an EMC design decision
The cable shield may terminate to a connector shell or follow another manufacturer-defined arrangement. Pin 5 is not a universal shield contact.
Follow the device, cable and plant grounding plan.Cordset selection
Specify the complete connection, not just "M12 cable."
A connector can mate mechanically and still be electrically wrong, environmentally weak or unsuitable for continuous motion. Put these six items on the purchase request.
Coding and positions
State A, B, D, X or the required power coding, plus 3-, 4-, 5- or other position count.
Gender at each end
Specify plug or socket and whether the opposite end is another connector or free leads.
Straight or angled body
Check tool access, cable exit, bend clearance and whether the angled direction can be oriented correctly.
Electrical rating
Match conductor count, cross-section, voltage, current, signal type, shielding and any network category.
Cable material and motion
Choose PVC, PUR or another jacket for oil, chemicals, welding, washdown, drag-chain, torsion and temperature needs.
Sealing and accessories
Verify the mated IP requirement, gasket, torque, cap for unused ports and strain relief. An unmated connector is not sealed by its mating rating.
Installation sequence
Build one verified map from device function to connector pin to PLC terminal.
Keep the sensor data sheet, cordset drawing and PLC input diagram together. The goal is not merely continuity; it is a complete electrical path with the right polarity, load and logic.
For a field-wireable connector, number each conductor before closing the shell. For a molded cordset, use the manufacturer's continuity map rather than opening or modifying the connector.
Identify the exact models
Record the sensor, cordset, junction block or IO-Link master, and PLC input card part numbers.
Isolate power
Follow the machine's approved electrical isolation and verification procedure before touching the circuit.
Confirm mechanical identity
Check coding, gender, position count, keyway, viewing direction and connector condition.
Map every active function
Write L+, L-, output, C/Q, analog return and extra power beside their documented pin numbers.
Verify the disconnected cable
Use continuity only on an isolated cordset or wiring assembly to confirm pin-to-core mapping and absence of shorts.
Check the controller side
Confirm PNP/NPN compatibility, input common, load current, analog input type or IO-Link port class.
Mate and secure correctly
Align the key, protect the seal, route the cable without strain and tighten to the specified method.
Commission one state at a time
Verify supply at the device, sensor indication, PLC state, target-present/absent logic and fault response.
Pre-power gate
Do not energize the connector until all eight checks are complete.
Use this commissioning gate for a new sensor, replacement cordset, field-wireable connector or control-panel modification.
Checks completed
0 / 8Hold power. Build the verified pin map first.
Fault finding
Troubleshoot the connection in layers instead of swapping wires.
Start with the model and pin map, then separate power, output topology, controller configuration, cable integrity and mechanical contact. This prevents a good sensor from being blamed for an incompatible input card or mirrored pin view.
- Use continuity testing on a disconnected passive cordset, not across powered sensor electronics.
- Measure supply between the documented L+ and L- contacts at the sensor under representative load.
- Interpret output voltage with the exact PNP/NPN circuit, load, leakage current and residual voltage in mind.
- For IO-Link, check port mode, port class, IODD/device recognition and the C/Q path before changing pin assignments.
| Observed symptom | Likely connection causes | Structured check |
|---|---|---|
| Sensor LED is off | No supply, reversed polarity, wrong pin view, damaged cable or supply protection has opened. | Verify the exact L+/L- pins, measure supply at the device, inspect the connector and isolate the cable before continuity testing. |
| LED changes but PLC does not | PNP/NPN mismatch, wrong PLC common, Pin 2/4 confusion, wrong input address or load incompatibility. | Trace the documented output pin to the PLC channel, verify input common and monitor both sensor LED and live PLC input state. |
| Input is stuck on or off | NO/NC logic mismatch, short to supply/return, target always present, leakage/residual voltage or wrong output channel. | Test target absent/present states, inspect cable shorts and compare measured behavior with the exact output circuit. |
| Signal drops when cable moves | Bent/recessed contact, loose coupling, cable break, unsupported bend or unsuitable continuous-flex cordset. | Power down, inspect contacts and seal, verify coupling, isolate the cable and test while gently flexing only within its permitted use. |
| IO-Link device stays offline | Port in SIO/DIO mode, C/Q not on Pin 4, wrong Class A/B cabling, voltage issue or incompatible port configuration. | Confirm master port mode and class, Pin 4 continuity, device supply and the master diagnostics for the connected port. |
| Analog value is noisy or wrong | Wrong input type, signal/return pin error, burden or impedance mismatch, poor routing, shielding error or ground-potential difference. | Use the device and analog-card diagrams together; verify current versus voltage mode, return path, scaling, routing and specified EMC termination. |
| Intermittent after washdown | Connector not fully mated, damaged seal, contamination, incorrect cap or an IP rating applied to an unmated connection. | De-energize, inspect for moisture/corrosion, replace damaged parts and restore the specified mating and sealing method. |
Do not use random bridging or live wire swapping as a diagnostic method.
Shorting a sensor output, feeding supply into C/Q or landing an analog signal on the wrong input can damage the sensor, master or PLC card. Isolate the circuit and prove the map first.
XSZ connection support
Need an XSZ sensor with the correct cable, connector and PLC output?
Send the target application and controller details before ordering. XSZ can help narrow the sensor family and confirm a suitable voltage, PNP/NPN output, NO/NC logic, cable length and connector option for sample validation.
- Sensor model or required sensing task
- Supply voltage and PLC input card
- PNP/NPN and NO/NC requirement
- Connector coding, gender and pin count
- Cable length, jacket and motion
- Machine photo or wiring diagram
Continue the wiring decision
Related XSZ sensor selection and troubleshooting guides
Frequently asked questions
M12 sensor connector pinout FAQ
What is the standard M12 pinout for a 3-wire sensor?
A common 3-wire A-coded DC switching sensor uses Pin 1 for L+ with a brown conductor, Pin 3 for L- or 0 V with a blue conductor, and Pin 4 for the switching output with a black conductor. Pin 2 is unused by that device. This is a common sensor profile, not a universal function map for every M12 product, so confirm the exact model diagram.
Is Pin 2 always the second output on a 4-wire M12 sensor?
No. Pin 2 may be a second or complementary switching output on some 4-wire sensors, but it can have another device-defined role. On an IO-Link Class A port it may be not connected, a digital input or a digital output; on a Class B port it is used for the positive side of the additional supply. Read both the device and port documentation.
Are M12 male and female pin positions mirrored?
The same numbered contacts connect to each other, but a plug mating-side view and a socket mating-side view appear mirrored. A 4-position A-coded plug drawing may show upper 4/3 and lower 1/2, while the socket mating-side drawing shows upper 3/4 and lower 2/1. Always check the keyway and the drawing's view caption.
Can a 4-core cordset be used with a 3-wire sensor?
Often yes, because many 3-wire sensors use a 4-position M12 connector and simply do not use Pin 2. The coding, gender, pin count, electrical ratings and contact assignment must still match. With a molded cordset, leave the unused contact as designed; with field wiring, terminate or isolate unused conductors according to the device and connector instructions.
Does PNP or NPN change the M12 pin numbers?
Not necessarily. A common PNP and NPN 3-wire sensor can both use Pins 1, 3 and 4. PNP sources positive current to the PLC input, while NPN sinks current toward 0 V. The PLC input common and input type must match the sensor topology, and the exact device diagram must still be checked.
Which pin carries IO-Link communication?
Pin 4 is the C/Q line for IO-Link communication and SIO operation. Pins 1 and 3 provide the device/electronics supply. Pin 2 and Pin 5 depend on whether the port is Class A or Class B and how the master and device are configured; they are not alternate C/Q contacts.
Is Pin 5 always shield or functional earth?
No. Pin 5 is not a universal shield or functional-earth contact. Five-core cordsets can use different fifth-conductor colors and devices can assign Pin 5 to an extra supply, signal, protective/functional connection or no connection. Shielded connector designs may terminate the shield through the connector shell. Follow the exact cable and device documentation.
Are M12 wire colors universal across all cables?
A common 4-core A-coded sensor cordset uses brown on Pin 1, white on Pin 2, blue on Pin 3 and black on Pin 4. Do not extend that memory to every cable family, fifth conductor or device function. Verify the cordset data sheet, especially for data, power, shielded and special-purpose assemblies.
Can a D-coded or X-coded M12 cable replace an A-coded sensor cable?
No. D-coded and X-coded connectors are used for industrial Ethernet families and have different keying and contact arrangements from a common A-coded sensor/actuator connector. The coding is intended to prevent incompatible mating. Order the coding specified by the connected device.
Technical references and image credits
Sources used to verify connector, IO-Link and output boundaries
- IEC 61076-2-101:2024 - M12 screw-locking circular connector family, contact-count envelope and coding provisions that prevent incompatible mating.
- Phoenix Contact 4-position A-coded M12 cordset data - plug and socket mating-side pin views, 4-core colors and product-specific mechanical/electrical data.
- Phoenix Contact 5-position A-coded M12 cordset data - 5-position plug/socket views and a cable example with a green-yellow fifth conductor.
- Phoenix Contact configurable 5-position cordset data - examples showing that fifth-conductor color and cable construction vary by selected cordset.
- OMRON E2B inductive proximity sensor data - product-specific M12 connector wiring examples and brown/white/blue/black contact sequence.
- IO-Link Design Guideline - Class A and Class B port assignments, Pin 4 C/Q, and cabling compatibility guidance.
- OMRON PNP/NPN output FAQ and Balluff sensor wiring fundamentals - sourcing/sinking current paths and PLC input matching.
- OMRON proximity sensor output terminology - PNP/NPN, NO/NC, leakage current and residual-voltage boundaries.
- TE Connectivity sensor communication overview - M12 D-coded and X-coded industrial Ethernet application/speed examples.
- Photography: electrical control panel by Magda Ehlers, electrician with cables by Shameer Vayalakkad Hydrose, control-panel technician by Bulat843, and multimeter troubleshooting by Onics Energy, all via Pexels.
Generic pin maps are planning aids. The final wiring authority is the exact sensor, cable assembly, connector, junction block or IO-Link master, and PLC input documentation for the installed part numbers. Apply the machine's approved electrical safety and commissioning procedures.