UART vs SPI vs I2C: Wires, Speed and Timing Compared

UART, SPI and I2C are the three serial buses almost every microcontroller has. They all move bytes one bit at a time, but they differ in how many wires they need, who sets the timing, how a device is chosen and how fast they go. This page puts them side by side, shows one frame of each, and works out how long the same 16 bytes take on each bus.

Learning objectives

  • Name the wires of UART, SPI and I2C and say which device drives each
  • Read one frame of each bus from a timing diagram
  • Count the bits on the wire for a transfer, including framing and acknowledgments, and turn that into a time
  • Choose a bus for a sensor, a display, a flash chip or a debug console, and explain why

Prerequisites

  • Binary and hexadecimal, and what a clock edge is
  • No prior bus experience

The three buses at a glance

UARTSPII2C
WiresTX and RX (plus ground)SCLK, MOSI, MISO and one CS per deviceSCL and SDA, shared by every device
ClockNone: both ends agree on a baud rateDriven by the masterDriven by the master; a slave may hold it low
Choosing a devicePoint to point: one device per pair of wiresA chip select line per deviceA 7-bit address in the first byte
DirectionFull duplexFull duplexHalf duplex
AcknowledgmentNoneNoneEvery byte is ACKed or NACKed
Typical speed9600 to 921600 baud1 to 50 MHz and more100 kHz, 400 kHz, 1 MHz
Driver typePush-pullPush-pullOpen drain with pull-up resistors
Typical useDebug console, GPS, Bluetooth modulesFlash, displays, ADCsSensors, EEPROMs, power monitors

UART: a frame with no clock

A UART has no clock wire, so the receiver has to know the bit time in advance. Each byte travels in a frame: the line idles high, a start bit pulls it low, eight data bits follow least significant bit first, and a stop bit returns it high. The format is written 8N1: 8 data bits, no parity, 1 stop bit. The receiver starts timing at the falling edge of the start bit and samples each bit in its middle. That is why both ends must agree on the baud rate to within a few percent.

UART frame of 0x41: start bit, eight data bits least significant bit first, stop bit
One UART frame, 8N1, carrying 0x41: 10 bit times for 8 bits of data.

SPI: a clock and a select line

SPI adds a clock wire that the master drives, so there is no rate to agree on: the slave just follows SCLK. The master pulls one chip select line low to choose a slave, then shifts a bit out on MOSI and in on MISO on every clock, so it sends and receives at the same time. There is no framing and no acknowledgment, so every bit on the wire is data, and the clock can run at tens of megahertz. The price is wires: each extra slave needs its own CS line. The two settings CPOL and CPHA decide which clock edge carries the data; Part 2 covers them.

SPI timing in all four modes: clock idle levels, data out and sampling points
SPI: the master drives the clock, so the data is sampled on a clock edge rather than at a timed point.

I2C: two wires, addresses and ACK

I2C needs only two wires for any number of devices. Both are open drain: a device can only pull a line low, and a pull-up resistor lets it rise. The master starts a transfer with a START condition, then sends a byte with a 7-bit address and a read or write bit; only the device with that address answers, by pulling SDA low for a ninth clock, the ACK. Every byte after that is also acknowledged. The pull-ups make the edges slow, which is why I2C runs at 100 kHz or 400 kHz rather than megahertz. Part 3 takes it apart.

I2C waveform of SCL and SDA showing START, one data bit, ACK and STOP
I2C: START and STOP are SDA edges while SCL is high; every byte ends with an ACK clock.

Worked example: 16 bytes on each bus

To compare them fairly, count every bit time the transfer occupies on the wire. For 16 bytes: UART sends 10 bits per byte. SPI sends exactly 8 clocks per byte. I2C sends a START, an address byte and a register byte, each with its ACK (9 bit times each), then 9 bit times per data byte and a STOP.

BusBit times for 16 bytesTimeShare that is data
UART 115200 baud, 8N11601388.9 us80%
SPI 10 MHz12812.8 us100%
I2C 100 kHz1641640.0 us78%
I2C 400 kHz164410.0 us78%

SPI at 10 MHz is about a hundred times faster than the other two, because its clock is faster, not because its framing is leaner: UART and I2C waste about the same share of the wire (20 and 22 percent). I2C at 100 kHz is the slowest here, but it reached a device on a shared two-wire bus with an address and got every byte acknowledged, which UART and SPI cannot do.

Choosing a bus

  • A debug console, a GPS or a Bluetooth module: UART. Two wires, no clock, and every terminal program speaks it.
  • A flash chip, a display or a fast ADC: SPI. It is the only one of the three fast enough for megabytes or a video frame.
  • Several slow sensors on one board: I2C. Two wires for all of them, and an ACK tells the firmware the device is there.
  • Long cables or a noisy environment: none of these as they are. RS-485 (UART over a differential pair) or CAN, as in the CAN bus project, are built for that.

Common mistakes

  • Crossing UART wires wrongly: one side's TX goes to the other's RX. Connecting TX to TX gives silence.
  • Comparing buses by clock rate alone. Count the bits on the wire: framing, addresses and ACKs all take time.
  • Forgetting the I2C pull-ups. With open drain outputs, nothing drives the lines high without them.
  • Sharing SPI's MISO between slaves whose outputs do not release the line when deselected. Part 2, exercise 4, shows the result.
  • Mismatched baud rates on a UART: the first byte may look almost right, and the errors grow toward the end of each frame.

Quick check

1. Which of the three buses can tell the master that a device is not present?

I2C: an absent device leaves SDA high during the ACK clock, so the master sees a NACK. UART and SPI send blindly.

2. How many bit times does one byte take on a UART set to 8N1?

10: a start bit, 8 data bits and a stop bit.

3. Why does an SPI slave not need to know the clock rate in advance?

The master sends the clock on SCLK, and the slave samples on its edges. A UART receiver has no clock wire, so it must time the bits itself.

Exercises

E1 (easy). How long do 100 bytes take over a UART at 9600 baud, 8N1?

1000 bit times at 9600 bits a second: 104.2 ms.

E2 (medium). An EEPROM page write of 32 bytes: I2C at 400 kHz against SPI at 10 MHz. The I2C part takes a 2-byte memory address; the SPI part takes an opcode and a 2-byte address.

I2C: START, address byte, 2 address bytes and 32 data bytes, each 9 bit times, and a STOP: 317 bit times, 792.5 us. SPI: 35 bytes of 8 clocks: 28 us. SPI is 28 times faster. Both chips then need several milliseconds to program the page, which often matters more.

E3 (medium). A UART divides a 16 MHz clock by 16 times a whole-number divisor. How close can it get to 115200 baud, and is that close enough?

The nearest divisor is 9, giving 111111 baud, 3.55 percent slow. The receiver samples the stop bit 9.5 bit times after the start edge, and that sample must stay within half a bit of the middle, so in theory the two ends may differ by less than 5.3 percent in total. 3.55 percent at one end uses most of that budget, so it works only if the other end is accurate and the edges are clean. A clock such as 18.432 MHz, which divides exactly, or a UART with a fractional divider removes the error.

E4 (hard). A sensor is read 1000 times a second: 6 bytes from a register, over I2C at 100 kHz. How busy is the bus?

Each read is a register write and a read with a repeated START: 84 bit times, 840 us. A thousand of them take 840 ms of every second: the bus is 84 percent busy, with no room for another device. Moving to 400 kHz cuts it to 21 percent; for more, the sensor's SPI interface, if it has one, is the better choice.

Interview questions

  • Q1. Why does I2C need pull-up resistors and SPI does not? Answer: I2C outputs are open drain, so several devices can share a line and a slave can hold SCL low without a short circuit; the resistor pulls the line high when nobody pulls it low. SPI outputs are push-pull and drive both levels.
  • Q2. You need to talk to 8 identical sensors with the same fixed I2C address. What are your options? Answer: an I2C multiplexer that connects one branch at a time, separate I2C controllers, or parts with address pins set to different values.
  • Q3. A UART link works at 9600 baud but corrupts bytes at 115200. What do you check first? Answer: the baud rate error of each end's divisor at the higher rate, then signal integrity: cable length and edges.

Summary

  • UART: two wires, no clock, point to point, 10 bit times per byte at 8N1.
  • SPI: a master-driven clock, a chip select per device, full duplex, fastest of the three.
  • I2C: two open drain wires shared by many devices, with addresses and an ACK after every byte.
  • Compare buses by counting every bit time on the wire, not by the clock rate alone.

Related

Sources

Last verified

Every number on this page was computed and checked on 27 November 2026.