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).

AspectUARTSPII2C
WiresTwo signal wires (TX and RX) plus groundFour signal wires (SCLK, MOSI, MISO) plus one chip-select (CS) per deviceTwo shared wires (SDA and SCL) plus ground, with pull-up resistors
ClockAsynchronous: no clock line, so both sides must agree on the baud rateSynchronous: the master drives a clockSynchronous: the master drives a clock
TopologyPoint to point between two devicesOne master and several slaves, each slave needing its own CS lineSeveral masters and slaves share one bus
AddressingNoneChip-select line selects the device7-bit address (10-bit optional) sent at the start of each transfer
Typical speedFrom 9,600 to 115,200 bit/s up to a few Mbit/sOften 1 to 50 MHz, and higher on some parts100 kHz (standard), 400 kHz (fast), 1 MHz (fast-mode plus), 3.4 MHz (high-speed)
DirectionFull duplexFull duplexHalf duplex
Error checkingOptional parity bit and framing checkNone built inAcknowledge (ACK/NACK) after every byte
Pins as devices increaseTwo more pins for every additional linkOne more CS pin for every additional deviceNo additional pins
DistanceCan run longer with RS-232 or RS-485 driversShort, on the same boardShort, on the same board
Typical usesDebug console, GPS and Bluetooth modules, board-to-board linksFlash memory, SD cards, displays, fast ADCs and sensorsLow-speed sensors, EEPROM, real-time clocks, chip configuration

Figures are typical orders of magnitude and vary by process generation and product.

When to use which

UART
When you need the simplest possible link between two devices, a debug console or a module with a serial interface.
SPI
When you need speed: memory, displays, fast converters. The price is more pins as you add devices.
I2C
When you have many slow devices and few pins: sensors, small memories, configuration registers. Speed is limited and pull-up resistors are required.

FAQ

Which is faster, I2C or SPI?

SPI. It often runs at 1 to 50 MHz or more, while I2C runs at 100 kHz to 1 MHz in common modes, and 3.4 MHz in high-speed mode.

Why does I2C need pull-up resistors?

I2C devices only pull the lines low and release them to go high, so resistors pull the lines up. This lets many devices share two wires safely.

Do UART devices need a clock line?

No. UART is asynchronous, so both sides must be set to the same baud rate. A small baud-rate mismatch can garble characters.

How many pins does SPI need for many devices?

SPI needs shared SCLK, MOSI and MISO lines plus one chip-select pin per device, so the pin count grows with the number of devices. I2C needs only two pins regardless of the number of devices.

Check your understanding

What is a characteristic of serial communication with a UART?

  1. AThe sender drives a clock wire, and the receiver samples data with that clock
  2. BNo clock wire is used; both sides agree on a communication speed (baud rate), and a start bit marks each character
  3. CMany devices share one wire and are selected by address
Show answer and explanation

Answer: B. No clock wire is used; both sides agree on a communication speed (baud rate), and a start bit marks each character

A UART communicates asynchronously over two wires, transmit and receive (plus ground). The line idles at 1; a 0 start bit marks the beginning of a character, followed by the data bits and a 1 stop bit at the end. No clock is sent, so both sides must be configured for the same speed, such as 115200 bps. UARTs are commonly used for debug output and for connecting GPS and radio modules.

What is a characteristic of SPI communication?

  1. AIt is asynchronous without a clock, using only two wires
  2. BIt is synchronous with the master driving the clock, sends and receives simultaneously, and selects devices with chip-select lines
  3. CIt selects devices by address, so two wires suffice for any number of devices
Show answer and explanation

Answer: B. It is synchronous with the master driving the clock, sends and receives simultaneously, and selects devices with chip-select lines

SPI is synchronous communication in which, on the clock driven by the master, data flows simultaneously on a master-to-slave line and a slave-to-master line. Each device gets its own chip-select (CS) line, and only the device whose CS is pulled low communicates. Its simplicity allows clocks of tens of MHz, so it often connects fast parts such as flash memory, displays and ADCs.

What is a characteristic of I2C communication?

  1. AEach device needs a dedicated chip-select line
  2. BSeparate transmit and receive lines allow both directions at once
  3. CSeveral devices share two wires, clock (SCL) and data (SDA), and the partner is selected by address
Show answer and explanation

Answer: C. Several devices share two wires, clock (SCL) and data (SDA), and the partner is selected by address

I2C is synchronous serial communication that connects several devices with only two wires, SCL and SDA. The master first sends the partner's 7-bit address, and only the device with that address responds. The lines are open-drain, pulled up to 1 by resistors so any device can pull them low. It suits parts where few wires matter more than speed, such as temperature and acceleration sensors and EEPROMs.

  1. On a 115200 bps UART using 8 data bits, no parity and 1 stop bit (8N1), roughly how many bytes can be sent per second?
  2. Which set of four signals is generally used by SPI?
  3. In I2C, how does the receiver of a data byte acknowledge it?

Practice Embedded Systems & Firmware questions

Key terms explained

UART
A circuit for asynchronous serial communication without a clock wire, in which both sides agree on a baud rate and characters are framed by start and stop bits.
SPI
Serial Peripheral Interface: synchronous serial communication in which data is exchanged in both directions on a master-driven clock, with devices selected by chip-select lines. Used for fast parts.
I2C
A synchronous serial bus connecting several devices on two wires, clock (SCL) and data (SDA), selecting the partner by address. The lines are open-drain with pull-ups.
GPIO
General-purpose input/output: microcontroller pins that software can configure as inputs or outputs, used for reading switches, lighting LEDs and so on.

Related comparisons