Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

Every way two chips talk

UART, I²C, SPI, 1-Wire, a shift register, CAN, USB, or a protocol of your own on top. Distance, speed, wire count and how many devices share the bus decide which.

Most of the time the other chip decides: its datasheet names the bus. When you do get a choice, ask how many devices, how far, how fast, and how many pins you can spare.

  • Two devices, point to point, often another board or a PC → UART: TX to RX, RX to TX, a shared ground, both ends set to the same baud rate in advance.
  • Several slow peripherals on two wires (sensors, a small display, a real-time clock) → I²C: one shared open-drain bus with pull-ups, each device picked by its 7-bit address.
  • A fast device (a display, an SD card, a fast ADC) → SPI: a clock, a data line each way, and one chip-select per device. Every transfer is a two-way swap.
  • Many sensors on one data pin, slowly → 1-Wire (the DS18B20), each found by its ROM code; microsecond-timed, so it costs the sketch time.
  • More plain digital inputs or outputs, not a conversation → a shift register (74HC595 out, 74HC165 in).
  • Long cables, electrical noise, many nodes (vehicles, machines) → CAN, through a transceiver, terminated at both ends.
  • Be a keyboard or a serial port to a computer → USB device mode, on a board whose chip has native USB.

Whatever the bus, your own messages on top of it need a frame: a start byte, a length, a version and a CRC.

Point to point

Section

UART

An 8N1 frame, least significant bit first, 10 bit times per byte; TX to RX with a shared ground.

How many bits per second a serial link sends; both ends must agree.

Example

At 115,200 baud, 8N1, at most 11,520 bytes a second: each byte takes 10 bit times.
The common UART format: 8 data bits, no parity, 1 stop bit.

A shared bus with addresses

Section

I²C

Two open-drain wires with pull-ups, a 7-bit address and a read/write bit, an acknowledge after every byte.

The 7-bit number that picks one chip on an I²C bus.

Example

A datasheet's write byte 0x78 is the 7-bit address 0x3C shifted left; Wire wants 0x3C.
An output that can only pull LOW; a pull-up resistor makes it HIGH.

A fast bus with chip-selects

Section

SPI

Clock, data out, data in, and a chip-select per device; the mode sets the clock's polarity and phase.

A line, usually active-low, that tells one SPI device it is being addressed.
The clock polarity and phase settings both sides of SPI must agree on.

One wire, or none at all

Several DS18B20s on one pin with one pull-up, and the DHT22's pulse-width frame.

Not a conversation, just more pins, with a 74HC595 for outputs and a 74HC165 for inputs.

Long cables and computers

A differential pair, 120 Ω at each end, and arbitration by identifier, where the losing frame is simply sent again.

Section

USB device mode

Presenting as a keyboard (HID) or a serial port (CDC) on a board with native USB.

Sending a signal as the difference between two wires, so noise affecting both cancels.

Reading and designing the conversation

Setup and hold against the clock edge, and decoding a byte from a UART, I²C or SPI trace.

A start byte, version, length, command, payload and CRC, parsed by a state machine that recovers from garbage.

A check value computed by polynomial division of the data bits, catching common corruptions.