SPI Series · Part 2 of 5
SPI vs I2C vs UART: Which Serial Protocol Should You Use?
SPI, I2C, and UART are the three protocols you'll meet again and again in embedded projects. They all move data serially, but they're built for different trade-offs. Here's how they compare, and when to reach for each one.
📊 Quick Comparison Table
| Feature | SPI | I2C | UART |
|---|---|---|---|
| Wires needed | 4+ (SCLK, MOSI, MISO, CS per device) | 2 (SDA, SCL) | 2 (TX, RX) |
| Speed | Fastest (tens of MHz) | Moderate (100kHz–3.4MHz) | Slower (~1–3 Mbps) |
| Duplex | Full duplex | Half duplex | Full duplex |
| Addressing | None — uses CS lines | 7/10-bit addresses | None — point to point |
| Multiple devices | Limited by CS pins | Many on one bus | One per UART pair |
| Clock line | Yes, shared | Yes, shared | No — preset baud rate |
⚡ Choose SPI When…
You need high throughput (displays, SD cards, flash), have spare CS pins, and want simple low-overhead hardware.
🔗 Choose I2C When…
You're wiring many low-speed sensors and want to save pins — multiple devices share just two wires.
📡 Choose UART When…
You're talking to exactly one device (GPS, Bluetooth module, PC) over a simple point-to-point link.
🌦️ A Practical Example
Imagine a weather station project: a BME280 sensor (available in both I2C and SPI variants), an SD card logger, and a GPS module. A common design uses I2C for the sensor to save pins, SPI for the SD card because it needs speed, and UART for the GPS since it's a single point-to-point device. Mixing protocols like this on one microcontroller is completely normal.
Up Next in This Series
Part 3: Clock Polarity, Phase & the 4 SPI Modes — the #1 cause of "why isn't my SPI working."
Comments
Post a Comment