I2C vs SPI vs UART: Differences and When to Use Each
These are the three serial interfaces you meet first in embedded systems. UART is a simple point-to-point link with no shared clock. SPI is a fast, four-wire bus where one master selects each device with a chip-select line. I2C is a two-wire bus where many devices share the same lines and are picked by address. The trade-off is mostly between speed (SPI), pin count (I2C) and simplicity (UART).
| Aspect | UART | SPI | I2C |
|---|---|---|---|
| Wires | Two signal wires (TX and RX) plus ground | Four signal wires (SCLK, MOSI, MISO) plus one chip-select (CS) per device | Two shared wires (SDA and SCL) plus ground, with pull-up resistors |
| Clock | Asynchronous: no clock line, so both sides must agree on the baud rate | Synchronous: the master drives a clock | Synchronous: the master drives a clock |
| Topology | Point to point between two devices | One master and several slaves, each slave needing its own CS line | Several masters and slaves share one bus |
| Addressing | None | Chip-select line selects the device | 7-bit address (10-bit optional) sent at the start of each transfer |
| Typical speed | From 9,600 to 115,200 bit/s up to a few Mbit/s | Often 1 to 50 MHz, and higher on some parts | 100 kHz (standard), 400 kHz (fast), 1 MHz (fast-mode plus), 3.4 MHz (high-speed) |
| Direction | Full duplex | Full duplex | Half duplex |
| Error checking | Optional parity bit and framing check | None built in | Acknowledge (ACK/NACK) after every byte |
| Pins as devices increase | Two more pins for every additional link | One more CS pin for every additional device | No additional pins |
| Distance | Can run longer with RS-232 or RS-485 drivers | Short, on the same board | Short, on the same board |
| Typical uses | Debug console, GPS and Bluetooth modules, board-to-board links | Flash memory, SD cards, displays, fast ADCs and sensors | Low-speed sensors, EEPROM, real-time clocks, chip configuration |
Figures are typical orders of magnitude and vary by process generation and product.