What are I2C, SPI, and UART, and which one should I use?

These are three common ways a microcontroller talks to other chips, like sensors, displays, and modules. They are not "better" or "worse" overall, they are different tools.

I2C (two wires, many devices)

  • Wires: SDA + SCL (plus power and ground)
  • Best for: sensors and small peripherals
  • Pros: multiple devices can share the same two signal wires
  • Cons: slower than SPI, and wiring/noise can matter on longer runs

SPI (fast, more wires)

  • Wires: SCK, MOSI, MISO, plus a separate CS pin per device
  • Best for: fast displays, SD cards, high speed sensors
  • Pros: fast and reliable
  • Cons: more wires, and each device needs a chip select pin

UART (classic serial)

  • Wires: TX and RX (plus power and ground)
  • Best for: GPS modules, Bluetooth modules, debugging, talking to another board
  • Pros: simple, widely supported
  • Cons: usually point-to-point (not many devices on the same two wires)

Which one should you choose?

  • Choose I2C for most sensors and small modules. It is the easiest wiring.
  • Choose SPI when you need speed (displays, SD cards).
  • Choose UART when a module specifically says "TX/RX" or "Serial", or when connecting two devices directly.
Bottom line

I2C is simplest for multiple sensors, SPI is fastest, and UART is the classic two-device serial link. Pick the protocol your module supports, then choose based on wiring and speed needs.

Related: Why is my sensor giving random readings? · 3.3V vs 5V: can I connect this sensor/module? · Which pins are safe to use on ESP32?