Skip to content
If this is your first visit, please click here to learn about shipping and delivery.
If this is your first visit, please touch here to learn about shipping and delivery.
SC16IS752 I2C and SPI dual UART expansion module with header strips

I2C vs SPI: What Is the Difference, and Which Should You Use?

I2C and SPI both let a microcontroller exchange data with peripheral chips, but they organise the connection differently. I2C is attractive when several modest-speed devices need to share a small number of pins. SPI is often useful when a peripheral needs a faster or more direct data path and extra control pins are available.

Neither is automatically the best choice. The peripheral may support only one interface, and the complete design includes logic voltage, cable layout, software support and timing—not just the headline clock rate. Start by asking what information needs to move and how often.

The practical differences

Typical I2C and conventional SPI arrangements
Property I2C SPI
Main signals SDA and SCL Clock, controller-out, controller-in and chip select
Device selection Address sent on the bus Usually a separate chip-select signal per peripheral
Electrical behaviour Ordinary bidirectional modes use open-drain signalling and pull-ups Commonly push-pull outputs with device-specific requirements
Data direction Shared bidirectional data line Can transfer in both directions simultaneously
Main design checks Address conflicts, pull-ups, capacitance and timing Clock mode, chip select, bus sharing and signal integrity

Ground and power are additional connections. Three-wire SPI variants, write-only peripherals and other arrangements also exist, so always consult the selected device's interface description.

How I2C shares two signal lines

The controller generates a transaction containing an address and a read/write direction, then exchanges data with the selected target. Acknowledgement bits help indicate whether the addressed receiver accepted a byte. The address identifies the device on the bus; register addresses inside that device are a separate concept.

The NXP I2C-bus specification defines standard operating modes, including 100 kbit/s Standard-mode and 400 kbit/s Fast-mode. Faster modes exist, but every participating device and the electrical implementation must support the chosen mode. Setting a faster clock in software does not upgrade the hardware.

Many devices use seven-bit addresses. Some datasheets also show an eight-bit value containing the read/write bit. Check what the software API expects before copying a hexadecimal value. Arduino's official Wire reference discusses addressing and board-dependent connections.

Address conflicts and pull-ups

Two identical sensors with the same fixed address cannot normally be addressed independently on one bus segment. Options include changing address straps where supported, using separate controller buses, or adding a suitable bus multiplexer. Do not assume every chip has a software-changeable address.

In normal bidirectional I2C, devices pull lines low and resistors bring them high. Pull-ups must connect to a voltage safe for all connected pins. Check breakout boards for fitted resistors: several boards in parallel produce a lower effective resistance.

For example, two 4.7 kΩ pull-ups on the same line act like approximately 2.35 kΩ. Whether that is suitable depends on rise-time requirements and device sink-current limits. A resistor value that works for a short bench connection is not automatically correct for a larger assembly.

How SPI selects and clocks a peripheral

Conventional SPI uses SCK, an outgoing data line and an incoming data line, commonly labelled MOSI and MISO. Some documentation uses COPI and CIPO instead. A chip-select signal identifies the intended peripheral; its active polarity and timing come from that peripheral's datasheet.

SPI does not define one universal command format or clock speed. The controller must match the device's bit order, clock polarity and clock phase. These last two settings are often expressed as modes 0 to 3. Analog Devices' SPI introduction explains the signals and clock modes.

Several devices can share the main signals if selection and output behaviour are suitable. Each unselected device must release the shared return line as required. A breakout with a poorly chosen buffer can interfere with another device even when its chip select is inactive.

Arduino's official SPI reference describes the library and transaction settings. Use the settings required by each peripheral and confirm the hardware SPI pins for the exact board. Pin assignments from an Uno example do not apply to every Arduino model.

Compare useful throughput, not only clock rates

Transfers contain more than application data. I2C includes addressing, acknowledgements and start/stop timing. SPI devices may require command bytes, dummy cycles or pauses while a conversion completes. Software and library buffering also influence performance.

Consider a hypothetical monochrome 128 × 64 display using one bit per pixel. A full image is 1,024 bytes. At a 400 kbit/s I2C clock, sending those bytes takes at least about 23 ms when allowing nine clock pulses per data byte, before command and transaction overhead. That is a lower-bound calculation, not a promised refresh rate.

If a display supports an 8 MHz SPI transfer, the raw 1,024-byte payload takes about 1 ms before overhead. That example explains why interface choice can matter for animation, but it does not imply that every display, controller or wiring arrangement supports 8 MHz.

Two practical project choices

A room monitor: a temperature sensor, real-time clock and small status display may share I2C comfortably if addresses are distinct and update requirements are modest. Check the total bus loading and avoid refreshing the display more often than needed.

A responsive graphical interface: SPI may be a better fit when a supported display must update frequently. Budget chip-select and other control pins, confirm memory requirements and check how the display shares the bus with storage or sensors.

PMD Way's graphic OLED display collection includes different controllers and interface variants. Compare the exact module's supported interface and library rather than choosing solely by screen size.

Electrical and troubleshooting checks

  1. Verify supply voltage and I/O voltage independently.
  2. Connect a shared reference for an ordinary non-isolated circuit and keep prototype wiring short.
  3. For I2C, check idle levels, address format and fitted pull-ups.
  4. For SPI, check chip select, clock mode, bit order and any reset or data/command pins.
  5. Run one peripheral first, then add others individually.
  6. Use a suitably rated logic analyser to compare transactions with the datasheet.

An I2C scanner can show that an address acknowledges; it does not prove the correct device, register map or voltage design. Likewise, activity on an SPI clock line does not prove the peripheral is selected or sampling on the correct edge.

Both interfaces are primarily suited to local electronic interconnection. There is no single cable-length limit independent of clock speed, loading and implementation. For a long or electrically noisy route, consider an interface designed for that environment rather than stretching an unmodified board-level bus.

Previous article Battery Power for Arduino Projects: Voltage Range, Runtime and Regulator Heat