DB9 Pinout Guide: DE-9 RS-232 Signals, Wiring and Null Modem
The 9-pin D-shaped connector everyone calls DB9 (its proper name is DE-9) is the classic RS-232 serial port. Three of its nine pins do almost all the work: pin 2 receives, pin 3 transmits and pin 5 is ground. This guide shows every pin, which cable you need, why you must never wire it straight to an Arduino or ESP32, and how to prove your wiring works in two minutes with a loopback test.
DB9 pinout: the nine pins
This is the standard PC-style (DTE) assignment. Most serial gear follows it, but always confirm with the manual of your device.
| Pin | Signal | Direction (seen from the PC) | What it does |
|---|---|---|---|
| 1 | DCD | in | Data Carrier Detect: modem says a link is up |
| 2 | RXD | in | Receive data |
| 3 | TXD | out | Transmit data |
| 4 | DTR | out | Data Terminal Ready: PC says it is alive |
| 5 | GND | n/a | Signal ground (the common reference) |
| 6 | DSR | in | Data Set Ready: device says it is alive |
| 7 | RTS | out | Request To Send: PC asks permission to send |
| 8 | CTS | in | Clear To Send: device says go ahead |
| 9 | RI | in | Ring Indicator: a modem sees an incoming call |
The only pins you need for a simple link are 2, 3 and 5. The other six are handshake and status lines for modems and older software.
Male, female and the mirror trap
Male has pins and is what you find on a PC. Female has sockets and is what you find on a modem or on most cables and adapter modules. Gender only tells you the shell type, not whether the device is DTE or DCE.
A pinout drawing can show the front of a connector or the back (solder side), and the two are mirror images. This is the number one reason homemade cables work backwards. Use this routine before you solder anything:
- Find the tiny numbers moulded beside the pins on the connector. They beat any drawing.
- Note that on a male connector seen from the front, pins run 1 to 5 left to right along the top.
- Remember that the female front view is the mirror (5 to 1).
- Check the finished cable with a multimeter in continuity mode, unpowered.
TX, RX and the cable you need
Every RS-232 device is either DTE (Data Terminal Equipment, such as a PC, controller or PLC) or DCE (Data Communication Equipment, such as a modem). A DTE sends on pin 3 and listens on pin 2. A DCE does the opposite, so a straight cable (pin 2 to 2, 3 to 3) joins them correctly.
If both ends are DTE, both would talk on pin 3 and listen on pin 2, so nothing arrives. A null-modem cable crosses the lines so one device's TXD meets the other's RXD.
Null-modem cables come in several flavours. The 3-wire version crosses only pins 2 and 3 and joins pin 5. Fuller versions also cross RTS/CTS and loop back DTR/DSR/DCD, and the exact loops differ between makers. Do not trust a cable's name: read its drawing or test continuity.
RS-232 is not UART logic
A microcontroller UART is TTL: 0 V for a 0 and 3.3 V or 5 V for a 1, idle HIGH. RS-232 is an electrical standard that uses both polarities and inverts the logic: a 1 (called mark) is a negative voltage and a 0 (space) is a positive one. Drivers swing about ±5 V to ±15 V, receivers need at least ±3 V, and anything between −3 V and +3 V is undefined.
| TTL UART (Uno, ESP32) | RS-232 (DB9) | |
|---|---|---|
| Logic 1 | 3.3 V or 5 V | −3 V to −15 V |
| Logic 0 | 0 V | +3 V to +15 V |
| Idle level | High | Negative |
| Typical use | Between chips and modules | Cables up to a few metres to PCs and equipment |
| Safe on a GPIO? | Yes | No: negative and high voltages can damage it |
Plugging a DB9 pin directly into an Arduino or ESP32 sends the wrong polarity and too much voltage into the pin. The fix is a level converter chip such as the MAX3232. It contains charge pumps that make the ± voltages from a single 3.3 V or 5 V supply, and it converts levels and polarity in both directions.
So to connect an Arduino, ESP32 or any other microcontroller to a DB9 port, use a MAX3232 breakout module between them. Choose one that runs from 3.3 V for 3.3 V boards such as the ESP32.
Flow control and serial settings
After the wiring is right, both ends must agree on the framing: baud rate, data bits, parity and stop bits. "9600 8-N-1" means 9600 bits per second, 8 data bits, no parity, 1 stop bit. It is a common default, not a law, so check the device manual. A wrong baud rate looks exactly like crossed wires.
Loopback test: to check a serial port on its own, connect pin 2 to pin 3 with a jumper wire, open a terminal on that port and type. If your characters appear back on screen, the port, driver and settings work. If not, the fault is in the port, not in the device you were about to connect.
Hardware flow control uses RTS and CTS (sometimes DTR and DSR) so a receiver can say "slow down". If your software has it switched on but the cable carries only pins 2, 3 and 5, the port opens and then nothing useful happens. Either wire pins 7 and 8 (and 4, 6 if needed) or turn flow control off at both ends.
Is every nine-pin D connector RS-232?
No. The shape is shared by several unrelated interfaces, and plugging in the wrong one can damage equipment.
| Interface on a DE-9 | Common pins | Notes |
|---|---|---|
| RS-232 | 2 RXD, 3 TXD, 5 GND | The layout in this guide |
| CAN (CiA 303-1) | 2 CAN_L, 3 CAN_GND, 7 CAN_H | Pins 5, 6 and 9 are optional shield, ground and power |
| RS-485 | Varies by maker | No universal assignment: read the product manual |
| Other (joysticks, proprietary) | Varies | Identify the interface before connecting anything |
Label what you build: write RS-232, TTL UART or CAN next to every connector, plus the viewing side and pin 1.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Nothing received | Wrong COM port, TX and RX not crossed, wrong cable type | Run the loopback test, then check DTE/DCE and use a null-modem if both ends are DTE |
| Garbage characters | Baud, parity or stop-bit mismatch | Set both ends to the same framing |
| Port opens but stalls | RTS/CTS flow control on with no wires | Turn flow control off or wire pins 7 and 8 |
| Works in one direction only | One data wire open or swapped | Continuity-test pins 2, 3 and 5 end to end |
| MCU resets or pin dies | RS-232 voltage reached a GPIO | Remove power and place a MAX3232 between the two |
| No output from the module | Not powered, or wrong supply for the logic level | Check VCC, and use 3.3 V with an ESP32 |
Always test cables unpowered with a multimeter. Never probe an unknown connector with a microcontroller pin.
Quick answers
Is DB9 the same as DE-9? Yes. DB9 is the popular name, DE-9 is the correct one (the "E" shell size holds 9 pins).
Can I connect DB9 straight to an Arduino? No. RS-232 levels are inverted and swing above and below 0 V. Use a MAX3232.
Which pins do I need? Pin 2, pin 3 and pin 5 for a basic link.
Why does my USB-to-serial adapter have TX/RX pins instead of a DB9? It is probably a TTL adapter. That goes straight to an MCU; a DB9 RS-232 adapter does not.
How long can an RS-232 cable be? The original standard allowed about 15 m at low speeds; shorter is safer at high baud rates.
Sources
Connector gender, pin arrangement and signal assignment can differ from product to product, so confirm against your device's manual.