Communication Buses

I2C, SPI and UART Compared

Compare the three most common serial buses in embedded electronics, I2C, SPI and UART, by wiring, speed, complexity and typical uses.

On this page
  1. UART: Simple Point-to-Point
  2. I2C: Two Wires, Many Devices
  3. SPI: Fast and Full-Duplex
  4. Side-by-Side Summary
  5. How to Choose
  6. Troubleshooting Tips
  7. Frequently Asked Questions

Microcontrollers rarely work alone. They read sensors, drive displays, store data in memory chips and talk to other processors. To do so using only a few pins, they rely on serial communication, where bits travel one after another along a wire. Three protocols dominate small embedded designs: UART, I2C and SPI.

They solve the same basic problem in different ways. Knowing their strengths makes it much easier to pick the right one for a project, or to understand why a chip offers only one of them.

UART: Simple Point-to-Point

UART stands for universal asynchronous receiver-transmitter. It is a link between exactly two devices, using two data wires: TX (transmit) from one side connects to RX (receive) on the other, and the reverse. A shared ground completes the circuit.

The key word is asynchronous. There is no clock wire. Both sides agree in advance on a speed, the baud rate, such as 9600 or 115200 bits per second. Each byte is wrapped in a frame:

  • A start bit that pulls the line low.
  • Typically eight data bits.
  • An optional parity bit for simple error detection.
  • One or more stop bits that return the line high.

The receiver uses the start bit to synchronize and then samples each bit at the agreed rate. If the two baud rates differ too much, the data becomes garbled, which is the most frequent UART problem.

UART is easy to use and ideal for debug consoles, GPS modules, Bluetooth modules and links between two microcontrollers. Its limits are that it connects only two devices (without extra hardware), and its speed is modest.

I2C: Two Wires, Many Devices

I2C, pronounced "eye squared see," uses just two wires shared by every device on the bus: SDA for data and SCL for the clock. Devices connect in parallel, and each has a unique address, commonly seven bits.

One device is the controller (formerly called master) and generates the clock. The others are targets (formerly called slaves). A transaction goes like this:

  1. The controller sends a start condition.
  2. It sends the target's address plus a bit indicating read or write.
  3. The addressed target replies with an acknowledge bit.
  4. Data bytes follow, each acknowledged by the receiver.
  5. The controller ends with a stop condition.

The lines are open-drain, meaning devices only pull them low, and pull-up resistors return them high. Forgetting the pull-ups is a very common reason an I2C bus does not work.

I2C is great for connecting many low-speed devices, such as temperature sensors, real-time clocks and small displays, using only two pins. Speeds run from 100 kHz standard mode to 400 kHz fast mode and above. The costs are slower transfer, address conflicts when two chips share the same address, and sensitivity to wire length and capacitance.

SPI: Fast and Full-Duplex

SPI, or Serial Peripheral Interface, trades extra wires for speed. It typically uses four signals:

  • SCLK: The clock, driven by the controller.
  • MOSI: Data from controller to target.
  • MISO: Data from target to controller.
  • CS or SS: A chip select line, one per target, pulled low to choose which device is addressed.

Because data goes out and comes in at the same time on separate lines, SPI is full-duplex. The clock is shared, so no baud rate agreement is needed, and speeds can reach many megahertz. There is no addressing or acknowledgment. If you want to talk to a device, you pull its chip select low.

SPI suits fast peripherals such as flash memory, SD cards, displays and ADCs. The drawback is pin count: each additional target needs another chip select pin, or a daisy-chain arrangement. SPI also has no built-in error checking or flow control, and it has four modes that set clock polarity and phase, which must match between devices.

Side-by-Side Summary

  • Wires: UART uses 2, I2C uses 2, SPI uses 3 plus one chip select per device.
  • Clock: UART has none, I2C and SPI use a clock line.
  • Devices: UART links 2, I2C links many through addresses, SPI links many through chip selects.
  • Speed: SPI is generally fastest, I2C is moderate, UART depends on the baud rate.
  • Complexity: UART is simplest in wiring, I2C needs pull-ups and addressing, SPI needs more pins.
  • Direction: UART and SPI are full-duplex, I2C is half-duplex.

How to Choose

  1. If you need a simple link between two devices, or a debug console, choose UART.
  2. If you have many slow sensors and few spare pins, choose I2C.
  3. If you need high throughput, such as for a screen, memory or a fast ADC, choose SPI.
  4. Check what the chip supports. Many parts offer only one interface, and some offer two.

Troubleshooting Tips

  • Verify voltage levels match. Mixing 3.3 V and 5 V logic may need level shifters.
  • Use a logic analyzer or oscilloscope to watch the real signals.
  • Keep wires short at high speed, especially for SPI and I2C.
  • For I2C, check addresses, pull-up values and bus capacitance.
  • For UART, confirm baud rate, data bits, parity and stop bits on both sides.

Frequently Asked Questions

Can I connect many devices to one UART?

Not directly, because UART is point-to-point. You can use additional UART ports, a multiplexer or a different standard such as RS-485, which supports multi-drop networks.

Why does I2C need pull-up resistors?

Devices only pull the lines low and never drive them high. The resistors return the lines to a high level when no device is pulling, which forms the logic one.

Is SPI always faster than I2C?

In practice yes, because it uses a dedicated data line in each direction and often runs at much higher clock rates. The actual speed depends on the chips, the wiring and the microcontroller.