Select the appropriate serial protocol based on required data throughput, wiring simplicity, distance, and device count:
| Feature | UART (Universal Asynchronous Receiver-Transmitter) | SPI (Serial Peripheral Interface) | I2C (Inter-Integrated Circuit) |
|---|
| Communication Type | Asynchronous (no shared clock wire) | Synchronous (dedicated `SCLK` wire) | Synchronous (shared `SCL` wire) |
| Duplex Mode | Full-Duplex (simultaneous TX & RX) | Full-Duplex (simultaneous MOSI & MISO) | Half-Duplex (bidirectional single `SDA` line) |
| Required Signal Wires | 2 wires: `TX`, `RX` (+ `GND`) | 4+ wires: `MOSI`, `MISO`, `SCLK`, `CS` (+ `GND`) | 2 wires: `SDA`, `SCL` (+ `GND` + Pull-up resistors) |
| Typical Data Speed | 9,600 bps – 1 Mbps (up to 4+ Mbps on modern MCUs) | 1 MHz – 50+ MHz (fastest board-level bus) | Standard: 100 kHz / Fast: 400 kHz / Fast+: 1 MHz |
| Maximum Devices | Point-to-point (2 devices only per port) | 1 Master + Multiple Slaves (1 `CS` pin per slave) | Up to 127 devices (7-bit addressing) on 2 wires |
| Hardware Pull-Ups | Not required (push-pull drivers) | Not required (push-pull drivers) | Mandatory (`2.2 kΩ – 10 kΩ` on `SDA` and `SCL`) |
| Max Cable Distance | Moderate (~1–3 m TTL; up to 1,200 m via RS-485) | Very Short (< 15–30 cm on PCB/harnesses) | Short (< 0.5–1 m; limited by 400 pF bus capacitance) |
| Common Applications | GPS/GNSS, telemetry radios, RC receivers (CRSF/SBUS), USB-to-Serial debug | IMUs (gyros/accelerometers), SD cards, flash memory, high-speed TFT displays | Barometers, magnetometers (compasses), OLED displays, EEPROMs, BMS monitors |
UART transmits data asynchronously byte-by-byte without a shared clock signal. Both devices must be pre-configured to the exact same timing parameters.
A standard UART packet (`8N1` configuration) consists of:
SPI is a high-speed synchronous master-slave bus ideal for real-time sensors (such as flight controller IMUs) and bulk memory transfers.
Master and Slave must match one of four clock timing modes defined by Clock Polarity (`CPOL`) and Clock Phase (`CPHA`):
| SPI Mode | CPOL (Idle Clock State) | CPHA (Data Sampling Edge) |
|---|
| Mode 0 (Most Common) | `0` (Clock idles `LOW`) | `0` (Sampled on rising edge, shifted on falling edge) |
| Mode 1 | `0` (Clock idles `LOW`) | `1` (Sampled on falling edge, shifted on rising edge) |
| Mode 2 | `1` (Clock idles `HIGH`) | `0` (Sampled on falling edge, shifted on rising edge) |
| Mode 3 | `1` (Clock idles `HIGH`) | `1` (Sampled on rising edge, shifted on falling edge) |
I2C allows up to 127 peripheral devices to share just two wires—`SDA` (Serial Data) and `SCL` (Serial Clock)—using unique 7-bit hardware addresses.
Connecting a `5.0 V` device to a `3.3 V` microcontroller without level translation can permanently damage non-5V-tolerant GPIO pins:
When a sensor or peripheral fails to communicate, diagnose the bus systematically:
Electronics Reference: 1. Diodes & Transistors | 2. Integrated Circuits (ICs) | 3. Communication Buses (UART, SPI & I2C)