Software That Lasts

Serial, I2C & SPI

14 minStudent plan

How chips talk to each other: three protocols, what each costs in pins and speed, and when to pick which.

After this lesson you can

  • Choose between UART, I2C and SPI for a job
  • Say what each wire in each protocol does
  • Debug a device that is not responding

UART serial

The simplest link is asynchronous serial, one wire each way: TX out, RX in. Cross them over, one device's TX goes to the other's RX.

Asynchronous means there is no shared clock, so both ends must agree the speed in advance. That is the baud rate, and 9600 or 115200 are conventional. Set them differently at each end and you receive perfectly formed nonsense, which is the classic first fault.

Serial.begin(9600) in setup() opens the port, and Serial.println() sends a line. It is your main debugging tool as well as a way to talk to GPS modules, Bluetooth adapters and other boards. Its limits are that it is point to point and relatively slow.

In the full lesson

  1. UART serial
  2. I2C
  3. SPI, and choosing between them

This lesson comes with the Student plan. The first module of Programming is free.