Architecture and Hardware

Embedded Communication Protocols: UART, SPI, I2C, CAN and More

How UART, SPI, I2C, CAN and other embedded protocols work, how synchronous and asynchronous links differ, how bus arbitration works, and how to choose.

On this page
  1. What a communication protocol does in an embedded system
  2. Ways to classify embedded communication
  3. UART
  4. SPI
  5. I2C
  6. CAN
  7. Other protocols worth knowing
  8. Comparison table
  9. Arbitration: what happens when two devices talk at once
  10. How to choose a protocol
  11. Common pitfalls

Almost every embedded system has to move data, whether between the microcontroller and a sensor on the same board, between two boards in the same box, or between devices spread across a car or factory. The rules for that exchange make up a communication protocol: how bits are signalled, how they’re timed, how devices are addressed and how errors are detected.

This guide covers the protocols you’ll meet most often in embedded work (UART, SPI, I2C and CAN), the ideas that distinguish them, and how to pick one. For where communication fits in the bigger picture, see our embedded system architecture guide.

What a communication protocol does in an embedded system

A protocol answers a set of practical questions:

  • Physical signalling: which voltage levels mean 0 and 1, and whether the signal is single-ended or differential?
  • Timing: how does the receiver know when to sample each bit?
  • Framing: where does a message start and end?
  • Addressing: if several devices share the wires, how is one selected?
  • Access control: who is allowed to transmit, and what happens if two try at once?
  • Error handling: are errors detected, acknowledged or retried?

Some protocols, like SPI, define very little beyond the wires and clocking. Others, like CAN, define message formats, priorities and error handling in detail.

Ways to classify embedded communication

Serial vs parallel

Parallel interfaces send several bits at once over several wires, such as an 8-bit data bus to an older LCD. Serial interfaces send bits one after another over one or a few wires. Most modern embedded communication is serial, because it needs fewer pins and fewer PCB traces, and it handles longer distances better.

Synchronous vs asynchronous

This is one of the most important distinctions.

  • Synchronous communication shares a clock signal between devices. The receiver samples data on a clock edge, so both sides stay aligned even if the clock speed varies. SPI and I2C are synchronous.
  • Asynchronous communication has no shared clock. Both sides agree on a bit rate in advance (the baud rate), and the receiver resynchronizes on a start bit at the beginning of each character or frame. UART is the classic example. CAN is also asynchronous in this sense: nodes resynchronize on signal edges rather than following a separate clock wire.

Synchronous links can usually run faster over short distances, and they tolerate clock variation because the clock travels with the data. Asynchronous links save a wire and work well over longer cables, but both sides’ clocks need to be reasonably accurate. For a broader look at the word, see our explainer on what “asynchronous” means.

Simplex, half-duplex and full-duplex

  • Simplex: data flows one way only.
  • Half-duplex: both directions, but only one at a time (I2C, CAN, RS-485 two-wire).
  • Full-duplex: both directions at once (UART with separate TX and RX lines, SPI).

On-board (intra-system) vs between devices (inter-system)

Some protocols are designed for chips on the same board, a few centimetres apart. I2C and SPI fall in this group. Others are designed for cables between boards or devices: UART over RS-232 or RS-485, CAN, USB and Ethernet. Pushing an on-board protocol over long cables is a common source of unreliable designs.

UART

A UART (universal asynchronous receiver-transmitter) is a peripheral that sends and receives asynchronous serial data. Strictly speaking, UART is the hardware block, and the format it produces is often just called “serial”.

  • Wires: TX (transmit), RX (receive) and a shared ground. TX on one device connects to RX on the other.
  • Framing: each character starts with a start bit (low), followed by typically 8 data bits, an optional parity bit, and one or more stop bits (high). “8N1” means 8 data bits, no parity, 1 stop bit.
  • Speed: set by the agreed baud rate. 9600 and 115200 baud are very common defaults, and many UARTs can go considerably faster.
  • Topology: point-to-point between two devices.
  • Duplex: full-duplex, since TX and RX are separate lines.

UART is used for debug consoles, GPS modules, Bluetooth and cellular modules (often controlled with text “AT” commands), and bootloaders. Microcontroller UART pins use logic-level voltages (often 3.3 V or 5 V). For longer distances, the same data format is sent through a transceiver chip using RS-232 or RS-485 signalling. RS-485 is differential, multi-drop and common in industrial systems.

SPI

SPI (Serial Peripheral Interface) is a synchronous bus with one controller and one or more peripherals. It originated at Motorola. There’s no single formal standard, so details vary between devices.

  • Wires: a clock (SCLK), a controller-to-peripheral data line (traditionally MOSI, also called COPI or SDO), a peripheral-to-controller data line (MISO, also CIPO or SDI), and a chip-select line (CS) for each peripheral.
  • Addressing: none on the bus. The controller selects a peripheral by pulling its chip-select line low.
  • Speed: often several MHz to tens of MHz, depending on the parts and the board layout.
  • Duplex: full-duplex. Data shifts out and in at the same time.
  • Modes: four clock modes (0–3), set by clock polarity (CPOL) and phase (CPHA). Controller and peripheral must agree.

SPI suits higher-throughput peripherals: SD cards, flash memory, displays, fast ADCs and some radio modules. Its downside is pin count, since every extra peripheral normally needs another chip-select line.

I2C

I2C (Inter-Integrated Circuit, also written I²C or IIC) was developed by Philips, whose semiconductor business is now NXP. It’s a synchronous, two-wire, multi-device bus.

  • Wires: SDA (data) and SCL (clock), plus ground. Both lines are open-drain: devices can only pull them low, and pull-up resistors pull them high.
  • Addressing: each device has an address, usually 7-bit, and the controller starts each transaction by sending it. Many sensors let you pick between two or more addresses with a pin.
  • Speed: standard mode is 100 kHz and fast mode 400 kHz. Fast-mode Plus (1 MHz) and higher-speed modes exist but aren’t supported by every device.
  • Acknowledgement: the receiver acknowledges each byte by pulling SDA low (ACK). A missing ACK signals a problem.
  • Duplex: half-duplex.

I2C is the go-to bus for sensors, EEPROMs, real-time clocks, port expanders and small displays. It needs only two pins for many devices. The trade-offs are modest speed and sensitivity to bus capacitance, which limits it to short distances. Pull-up resistor values matter too. Closely related variants include SMBus (used for battery and power management) and I3C, a newer successor.

CAN

CAN (Controller Area Network) was developed by Bosch for vehicles. It’s now standardized as ISO 11898 and widely used in automotive, industrial and medical equipment.

  • Wires: a differential pair, CAN_H and CAN_L, with a 120 Ω termination resistor at each end of the bus.
  • Topology: a multi-drop bus where any node can transmit (multi-master).
  • Addressing: messages carry an identifier that describes the content and sets its priority, rather than addressing a specific node. Every node sees every message and filters for the ones it needs.
  • Speed: classical CAN goes up to 1 Mbit/s, with lower rates needed on longer buses. CAN FD allows a faster data phase and larger payloads (up to 64 bytes versus 8).
  • Robustness: differential signalling resists noise, and the protocol includes CRC checks, acknowledgements, automatic retransmission and fault confinement that can take a misbehaving node off the bus.

A microcontroller usually needs a separate CAN transceiver chip between its CAN controller and the bus wires.

Other protocols worth knowing

  • RS-485 and Modbus: RS-485 is a differential, multi-drop physical layer that can run over long cables. Modbus RTU is a simple request/response protocol often run over it in industrial equipment.
  • LIN: a low-cost, single-wire automotive bus for simple functions like window switches and mirrors, often working alongside CAN.
  • 1-Wire: a Dallas/Maxim protocol that carries data (and optionally power) over one wire plus ground. It’s used by the DS18B20 temperature sensor and ID chips.
  • USB: used both to connect embedded devices to PCs and, with host support, to connect peripherals to embedded devices. More complex than UART but fast and universal.
  • Ethernet: higher bandwidth and standard networking. Increasingly common in industrial and automotive systems.
  • Wireless: Wi-Fi, Bluetooth Low Energy, Zigbee/Thread, LoRa and cellular, each trading range, data rate and power differently.

Above these links, networked devices often use internet protocols like TCP, UDP, HTTP or MQTT. Our article on the 7 network protocols and examples covers that layer.

Comparison table

UART SPI I2C CAN
Timing Asynchronous Synchronous Synchronous Asynchronous (edge resync)
Signal wires 2 (TX, RX) 4 + 1 CS per extra device 2 (SDA, SCL) 2 (differential pair)
Topology Point-to-point One controller, many peripherals Multi-device bus Multi-master bus
Device selection N/A Chip-select line Address in message Message ID + filtering
Duplex Full Full Half Half
Typical speed Up to ~1 Mbit/s common Several to tens of MHz 100 / 400 kHz common Up to 1 Mbit/s (faster data phase with CAN FD)
Typical distance Board to board; longer via RS-232/RS-485 On-board On-board Across a vehicle or machine
Built-in error checking Optional parity None ACK bits CRC, ACK, retransmission

Speeds and distances are typical rather than absolute limits. Real limits depend on the specific chips, cabling and layout.

Arbitration: what happens when two devices talk at once

On any shared bus, two devices might try to transmit at the same moment. Arbitration is the mechanism that decides who wins. For more on buses themselves, see our explainer on what a bus is in embedded systems.

Centralized arbitration

In centralized schemes, a single arbiter grants the bus. Devices request access, and the arbiter decides based on fixed priority, round-robin or a daisy chain where the grant passes from device to device. This is how internal processor buses typically handle multiple bus masters, such as the CPU and a DMA controller.

SPI avoids the problem by design: there’s one controller, and it alone decides which peripheral to talk to.

I2C arbitration

I2C supports multiple controllers on one bus. Because the lines are open-drain, a low level from any device overrides a high level. This is called wired-AND behaviour. While transmitting, each controller checks SDA. If it sent a 1 but sees a 0, another controller is sending a 0, so it has lost arbitration and stops transmitting. The winner never notices the contest, and its message goes through intact.

CAN arbitration

CAN uses the same principle at the heart of the protocol. A bus level is either dominant (logical 0) or recessive (logical 1), and dominant always overrides recessive. Every node starts transmitting its message identifier bit by bit while monitoring the bus. A node that sends recessive but sees dominant drops out and tries again later. As a result, the message with the lowest identifier wins, and it is never corrupted. This is called non-destructive bitwise arbitration. System designers give the most urgent messages the lowest IDs, so priority is built into the bus.

How to choose a protocol

Start from the parts and the physical layout:

  1. What do your chips support? Often the sensor or module decides for you. Many sensors offer only I2C, or both I2C and SPI.
  2. Distance and environment. On the same board: I2C or SPI. Between boards in a box: UART, SPI with care, or CAN. Long cables or electrically noisy environments: RS-485, CAN or Ethernet.
  3. Data rate. Displays, SD cards and fast ADCs favour SPI. Occasional sensor readings are fine on I2C.
  4. Pin budget. I2C uses two pins for many devices. SPI needs an extra chip-select per device.
  5. Number of nodes and who initiates. Several intelligent nodes that each need to send data suit a multi-master bus like CAN.
  6. Reliability needs. Safety-relevant or noisy applications benefit from CAN’s error detection and fault handling.
  7. Interoperability. Automotive, industrial and building systems often mandate specific protocols, such as CAN, Modbus or BACnet.

Common pitfalls

  • Crossed or uncrossed UART lines. TX must go to RX. Mismatched baud rates show up as garbage characters.
  • Missing I2C pull-ups, or several modules each adding their own so the combined resistance gets too low.
  • Voltage mismatch. Connecting a 5 V device to a 3.3 V microcontroller pin that isn’t 5 V-tolerant can damage it, so use level shifting where needed.
  • Wrong SPI mode. CPOL/CPHA mismatches produce shifted or garbled data.
  • Missing CAN termination. A CAN bus needs termination at both ends, and too many or too few terminators cause errors.
  • Running on-board buses over long wires. I2C in particular degrades quickly with cable capacitance.

A logic analyzer or an oscilloscope with protocol decoding is the most useful tool for debugging any of these.

The complete guide to architecture and hardware

Embedded System Architecture: Hardware and Software Components
Read the guide

Keep exploring

Guides from other topics

All topics →