M12 pinout: A, D and X-coding
The M12 is the sealed circular connector of industrial automation, with a 12 mm thread. Its coding, a mechanical key, prevents plugging a cable into the wrong use: A-coding for sensors, actuators and IO-Link, D-coding for 100 Mbit/s Ethernet, X-coding for Ethernet up to 10 Gbit/s.
By Hugues Orgitello · Updated ·
A-coded, 4 and 5 pins (sensors, actuators, IO-Link)
Assignment and wire colors per IEC 60947-5-2 for 3 and 4-wire proximity sensors, and per the IO-Link specification for the IO-Link column. Pin 5 only exists on the 5-pin version.
| Pin | Signal | Wire | IO-Link | Description |
|---|---|---|---|---|
| 1 | L+ | Brown (BN) | L+ | +24 V supply (Power) |
| 2 | Out 2 | White (WH) | I/Q (class A), P24 (class B) | Second output, complementary output or unconnected depending on the sensor (Signal) |
| 3 | L- | Blue (BU) | L- | 0 V (Ground) |
| 4 | Out 1 | Black (BK) | C/Q | Main switching output (Signal) |
| 5 | FE / NC | Gray (GY) | NC (class A), N24 (class B) | Functional earth or unconnected (Shield / earth) |
D-coded, 4 pins (10/100 Mbit/s Ethernet)
Assignment per IEC 61076-2-101, used by PROFINET and EtherNet/IP. Wire colors per PROFINET cabling. The last column gives the matching RJ45 pin. D-coding adds a second, smaller key, not drawn here.
| Pin | Signal | Wire | RJ45 | Description |
|---|---|---|---|---|
| 1 | TD+ | Yellow | 1 | Transmit, positive (Differential pair) |
| 2 | RD+ | White | 3 | Receive, positive (Differential pair) |
| 3 | TD- | Orange | 2 | Transmit, negative (Differential pair) |
| 4 | RD- | Blue | 6 | Receive, negative (Differential pair) |
X-coded, 8 pins (1 and 10 Gbit/s Ethernet)
Assignment per IEC 61076-2-109. The four pairs are separated by a cross-shaped shield; the key sits in the pin 1-2 quadrant. The last column gives the matching RJ45 pin (T568B wiring).
| Pin | Signal | RJ45 | Description |
|---|---|---|---|
| 1 | BI_DA+ | 1 | Pair A, positive (Differential pair) |
| 2 | BI_DA- | 2 | Pair A, negative (Differential pair) |
| 3 | BI_DB+ | 3 | Pair B, positive (Differential pair) |
| 4 | BI_DB- | 6 | Pair B, negative (Differential pair) |
| 5 | BI_DD+ | 7 | Pair D, positive (Differential pair) |
| 6 | BI_DD- | 8 | Pair D, negative (Differential pair) |
| 7 | BI_DC- | 5 | Pair C, negative (Differential pair) |
| 8 | BI_DC+ | 4 | Pair C, positive (Differential pair) |
An industrial sensor to design around an M12 connector, an IO-Link port to integrate, a move to industrial Ethernet? We design the board and pick the connectors with you.
M12 codings and what they are for
The coding is a key molded into the insulator: a D-coded cable does not fit an A-coded receptacle. The common ones are A (sensors, actuators, IO-Link, 24 V DC fieldbus), B (PROFIBUS and some fieldbuses), D (100 Mbit/s Ethernet), X (1 to 10 Gbit/s Ethernet), and for power L (up to 16 A DC, PROFINET power), T (DC), S and K (AC).
Seen from the front, a female receptacle is the mirror image of the male plug drawn here: pin 1 moves to the other side of the key. That is the most common source of error when drawing a panel connector from a cable drawing.
IO-Link: class A or class B port
IO-Link carries data on pin 4 (C/Q), as a point-to-point serial link, while keeping the classic switching mode. A class A port leaves pin 2 as a digital input or output. A class B port uses it, together with pin 5, for a second isolated supply (P24 and N24), useful for actuators that must be switched off separately.
Plugging a class A device into a class B port can put voltage on the device’s pin 2: check the class on both sides before wiring.
FAQ
- What are the wire colors of an M12 sensor cable?
- Per IEC 60947-5-2: pin 1 brown (+24 V), pin 2 white, pin 3 blue (0 V), pin 4 black (output), pin 5 gray. A 3-wire PNP sensor only uses brown, blue and black.
- What is the difference between M12 D-coding and X-coding?
- D-coding has 4 pins, so two pairs: it carries 10/100 Mbit/s Ethernet. X-coding has 8 pins, so four pairs separated by a cross-shaped shield: it carries Gigabit and 10 Gbit/s. The two do not mate with each other.
- How do you wire an M12 D-coded to an RJ45?
- M12 pin 1 to RJ45 pin 1 (TD+), M12 2 to RJ45 3 (RD+), M12 3 to RJ45 2 (TD−), M12 4 to RJ45 6 (RD−). RJ45 pins 4, 5, 7 and 8 stay free. Keep the pairs together: M12 pins 1 and 3 form the transmit pair.
- What does IP67 mean for an M12 connector?
- Dust-tight and protected against temporary immersion, per IEC 60529, but only once the plug is screwed onto the receptacle with its seal. A receptacle with no cap and no cable does not have that rating.
- IEC 61076-2-101, Circular connectors M12 with screw-locking (codings A, B, D...) (paid or members-only document)
- IEC 61076-2-109, Circular connectors M12 for data transmission up to 500 MHz (X-coding) (paid or members-only document)
- IEC 60947-5-2, Proximity switches (connector pinout and wire colors) (paid or members-only document)
- IEC 61076-2-111, Circular connectors M12 for power (codings L, S, T, K) (paid or members-only document)
- IO-Link Interface and System Specification V1.1.x (IEC 61131-9), Tables 12-13, Figure 26
Tables built from these documents and cross-checked against manufacturer datasheets. Always check the datasheet of the connector you actually use: some manufacturers number differently.
- RJ45 Ethernet pinout, T568A and T568B
- CAN, CAN FD and CAN XL bus
- Industrial IoT cybersecurity
- Electronic product industrialization
Other pinouts