Skip to main content

Serial & Bus Communication Protocols

Overview of common communication protocols used for interfacing sensors, peripherals, and other computers with the Raspberry Pi.

RS-232 (Serial)

RS-232 is a standard for serial communication transmission of data.

Hardware Flow Controls

Used to signal when the device is ready to send or receive data.

DTEDirectionDCEDescriptionActive
RTSRTSRequest to send (†)Low
CTSCTSClear to send (†)Low
DSRDSRData set readyLow
DTRDTRData terminal readyLow

† Primary flow control signals

Software Flow Control (XON/XOFF)

Uses specific characters embedded in the data stream to control the flow.

CodeMeaningASCIIHexKeyboard
XOFFPause transmissionDC313Control-S
XONResume transmissionDC111Control-Q

Disadvantages of Software Flow Control:

  1. Data Loss: Line noise can mask XOFF characters, causing buffer overruns.
  2. Link Lockup: Missing XON characters can prevent transmission from resuming.
  3. Data Collision: XON/XOFF characters cannot be used as literal data unless escaped.

I2C (Inter-Integrated Circuit)

I2C is a multi-master, multi-slave, packet-switched, single-ended, serial communication bus.

  • Pins: Uses two wires: SDA (Serial Data) and SCL (Serial Clock).
  • Addressing: Each device on the bus has a unique 7-bit or 10-bit address.
  • Speed: Standard mode (100 kbit/s), Fast mode (400 kbit/s), and High-speed mode (up to 3.4 Mbit/s).
  • Usage: Common for EEPROMs, RTCs (DS3231), and simple sensors (MPU6050).

SPI (Serial Peripheral Interface)

SPI is a synchronous serial communication interface used for short-distance communication, primarily in embedded systems.

  • Pins: Typically uses four wires: MOSI (Master Out Slave In), MISO (Master In Slave Out), SCLK (Serial Clock), and SS/CS (Slave Select / Chip Select).
  • Speed: Much higher speeds than I2C (often up to 10+ MHz).
  • Usage: SD cards, LCD displays, and high-speed ADCs.

1-Wire

A device communications bus system designed by Dallas Semiconductor (now Maxim Integrated).

  • Pins: Technically requires only one data line plus ground (often powered via a pull-up resistor on the data line, known as "parasite power").
  • Addressing: Each device has a unique, factory-programmed 64-bit ID.
  • Usage: Temperature sensors (DS18B20), electronic keys (iButton), and digital potentiometers.