What are the three common communication protocols? How do they (I2C, SPI, UART) work?

Fun fact:

If you’re familiar with software engineering interview prep, this is commonly known as the hardware equivalent of fizzbuzz for electrical engineers! :thinking:

Communication protocols are directly linked to the hardware interfaces people use in microcontroller development. More informally, think of the way in which different modules can talk to each other!

Any consumer electronic device you use relies on these different communication protocols which have individually have unique strengths.

UART: Universal Asynchronous Receiver/Transmitter

  • UART is the simplest and most commonly used serial communication protocol for the host to communicate with auxiliary units

    • Simplest, but slowest
    • Supports data transmission of <= 1 Megabit/second
  • Uses two datalines, one to transmit (TX) and another to receiver (RX)

  • Asyncronous serial transmission protocol (no clocks), so baud rate must be set equal for devices

  • Also referred as the RS232 Interface

UART is used in common applications like GPS receivers & bluetooth modules

UART Interface Diagram

SPI: Serial Peripheral Interface

  • Used for high-speed applications, supports speed up to 10-20 Megabits/second

    • SD Card Readers, RFID Modules, 2.4 GHZ Wireless Receivers/Transmitters use SPI
  • Operates at full-duplex where data can be sent and received simultaneously

  • Clock is generated by master device, so data transfer is synchronized

  • Similar to I2C, but specially designed for microcontrollers to connect

    • MOSI - Master Output Slave Input, it is used to transfer data from master device to slave device.
      MISO - Master Input Slave Output, it is used to transfer data from slave device to master device.
      SCLK - Serial Clock, it is clock output from master and used for synchronization.
      SS - Slave Select, it is used by master device to select one slave out of multiple slaves. It inserts active low signal to select the particular slave device.

iSPI Interface Diagram

I2C - Inter-Integrated Circuit

  • Simple communication protocol used to transfer data between a master(s) and slave devices. Bidirectional two-wire serial bus.
    Commonly used to run signals between integrated circuits mounted on the same PCB
  • Very common in consumer electronics devices for transmitting sensor data from the IC’s to the host MCU.
    • Think devices like electronic skateboards, Peleton bikes, smart IOT products
  • Supports data rates generally up to 400 kHz ( UART < I2C < SPI for speed)
  • Synchronous communication like SPI, so common clock signal between master and slave devices
  • Two lines for Clock (SCL) and Data (SDA)

I2C Interface

Reference Resources: