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.
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 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.
| Protocol | Speed | Wiring | Best for |
|---|---|---|---|
| UART | Moderate | 2 wires, point-to-point | Simple links, debug consoles, modules |
| SPI | Fast | 4 wires + 1 CS per device | High-speed displays, storage, sensors |
| I2C | Moderate | 2 wires, many devices | Many low-speed sensors, pin-constrained designs |
Try it: letting the target device's datasheet decide directly
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?
Many sensor/peripheral chips are designed to support only one specific protocol, which settles the choice before speed/pin trade-offs even come into play.