UART, I²C and SPI
The three buses that connect most sensors, displays and radio chips to a microcontroller, and how to choose between them.
Key points
- A UART link is asynchronous: there is no shared clock, so both ends must be set to the same baud rate. It uses one wire each way (TX and RX) plus ground, and connects exactly two devices.12
- I²C uses two open-drain lines, SDA (data) and SCL (clock), held high by pull-up resistors. Many devices share the bus, each selected by an address, normally 7 bits.3
- The I²C specification defines Standard-mode (100 kbit/s), Fast-mode (400 kbit/s), Fast-mode Plus (1 Mbit/s) and High-speed mode (3.4 Mbit/s), plus a unidirectional Ultra Fast-mode (5 Mbit/s).3
- SPI is synchronous and full-duplex: a clock, a data line in each direction and, in the usual wiring, a separate chip-select line per device. Clock polarity and phase give four 'modes', and the controller must use the mode each device expects.4
- Old pin names (MOSI, MISO, SS) still appear on many datasheets. A 2020 Open Source Hardware Association resolution recommends SDO and SDI (named from each device's own side) and CS. For pins that switch with the role, it first used COPI/CIPO, now printed on many boards; its current text uses PICO/POCI.56
- MIPI I3C is a newer two-wire bus intended as a successor to I²C: it is faster, supports in-band interrupts and can share the bus with many legacy I²C devices.7
Common mistakes
- Putting two I²C sensors with the same fixed address on one bus. Check the address options before choosing the second part.
- Running I²C over long wires off the board. It was designed for short connections on one board.
Where to go next
- Environmental sensors for VAHA: wiring, how readings reach the app, and two TVOC data-integrity gaps a whitepaper from our lab
- CAN, RS-485 and Ethernet in the field builds on this
Spotted a mistake, or found this useful?
Tell usSources
- UART: A Hardware Communication Protocol · Analog Devices · Reference
- nRF Connect SDK Fundamentals, Lesson 4: UART protocol · Nordic Semiconductor (DevAcademy) · Vendor page
- UM10204: I2C-bus specification and user manual · NXP · Standard
- Introduction to SPI Interface · Analog Devices · Reference
- A Resolution to Redefine SPI Signal Names · Open Source Hardware Association · Standard
- OSHWA: A Resolution to Redefine SPI Signal Names · OSH Park blog · News
- MIPI I3C · MIPI Alliance · Standard