Home / Learn Embedded C / Choosing UART, SPI or I2C

Choosing UART, SPI or I2C

A practical decision guide for picking the right serial protocol for a given job.

Quick summaryA practical decision guide for picking the right serial protocol for a given job.

How to think about this

The basic idea

Choosing between UART, SPI and I2C depends on required speed, number of devices, available pins, and whether the target device even supports a given protocol — there is rarely a single universally "best" choice.

Why this comes up

Picking the wrong protocol for a project's constraints (too few pins for SPI's per-device select lines, too slow for high-throughput SPI needs, or simply a device that only supports one specific protocol) causes avoidable redesign later.

The mechanics

In practice, the target peripheral chip's datasheet usually narrows the choice immediately (many sensors only support I2C, or only SPI) — this lesson's general comparison matters most when a device supports more than one option.

Where it is used

  • Hardware/protocol selection
  • Project planning
  • Peripheral datasheet review

Try it

A tiny decision helper picking a protocol from stated needsC: edit and run

A real decision is usually narrowed first by what the target device's datasheet even supports, as this lesson explains; this helper applies the remaining general trade-offs.

ProtocolSpeedWiringBest for
UARTModerate2 wires, point-to-pointSimple links, debug consoles, modules
SPIFast4 wires + 1 CS per deviceHigh-speed displays, storage, sensors
I2CModerate2 wires, many devicesMany low-speed sensors, pin-constrained designs

Try it: letting the target device's datasheet decide directly

A decision that is settled immediately by device supportC: edit and run

When a peripheral only supports one protocol, the general speed/wiring comparison never even comes into play.

Quick check

1. Which factor most often immediately narrows the protocol choice for a given peripheral device?