I2C vs SPI protocols: differences, pros & cons, use cases

author avatar

12 Jan, 2023

I2C and SPI are both serial communication protocols

I2C and SPI are both serial communication protocols

Developers are constantly seeking new high-performance protocols like USB4 and Thunderbolt. But low-end communication protocols are just as important. Here we consider the debate of I2C vs SPI, two serial communication protocols.

In the world of computing and electronic devices, communication is key. When assembling a complex system of individual components and devices, different parts of the system need to communicate with each other, and they can only do this via protocols: rules and procedures that allow two different devices to exchange information.

Different protocols are required for different forms of communication. For example, the protocol used to interface between, for example, a computer and a plug-and-play printer is different to the protocol used to transfer information between a microcontroller and a fan speed sensor.

The I²C and SPI protocols — both of which are serial communication protocols, as opposed to parallel ones — are each used for low-speed communication between microcontrollers and (usually onboard) peripherals, helping to simplify PCBs and reduce the amount of complicated wiring required. Despite their relatively slow speed, these protocols remain highly desirable due to their simplicity and affordability: when connecting simple peripherals, a more advanced protocol is simply not required.

This article considers the battle of I2C vs SPI in terms of the architecture, function, pros and cons, and common applications of the two protocols.

What is the I2C protocol?

i2c boardAn I2C board with GND, VCC, SDA, SCL wiring scheme

I²C (Inter-Integrated Circuit) is a serial communication protocol that is mostly used for connecting low-speed peripheral integrated circuits to processors and microcontrollers.

Developed in 1982 by Dutch company Philips Semiconductors, the I²C protocol was initially designed to connect a CPU to peripheral chips in a TV set in a straightforward way that used up minimal space on the microcontroller. Today, the protocol has many uses, from reading memory to controlling display brightness.

I²C is a multi-master protocol. Interestingly, it uses just two signal lines, a data line and a clock line:

  1. SDA (serial data)

  2. SCL (serial clock)

Using these two lines, the protocol can accommodate multiple slaves and masters. The protocol works by defining a 7-bit address for each slave device, data in 8-bit bytes, and control bits for starting and stopping communication. In terms of the physical I2C bus, two bi-directional wires are used for the two signal lines, in addition to a ground connection.

There are three different data rates available when using the I²C protocol: standard mode (100 kbps), fast mode (400 kbps) and high-speed mode (3.4 Mbps). However, even the high-speed mode falls short of the data rate offered by the comparable SPI protocol.

I2C advantages

The I²C protocol offers a few notable advantages that have contributed to its continued relevance over the last 40 years.

  • Bus topology: the I²C uses only two lines (two general-purpose I/O pins) and therefore takes up minimal circuit board space. Because of this, the protocol is one of the easiest to use when building a system.

  • Multi-master conflict handling: the I²C has some surprisingly advanced features such as multi-master conflict handling (i.e. during situations in which one master is attempting to write a zero and the other a one).

  • Clock stretching: if an I²C slave needs to go slower than the clock speed given by the master, it can use a clock stretching mechanism, enabled by the open-drain / pull-up resistor structure of the bus line.

  • Secure: the protocol can be used for security-sensitive applications like sensor connections, RFID, and biometric devices.[1]

I2C limitations

The I²C protocol also has its share of disadvantages, some of which may be sufficient to lead developers to choose another protocol such as SPI.

  • Speed: although the I²C protocol offers a nominal “high-speed mode” (not always available due to its need for specific I/O buffers) which can transfer data at 3.4 Mbps, the transfer rate is severely limited.

  • Half-duplex: while the protocol can provide communication in both directions, it can only do so in one direction at a time, not simultaneously in two directions.

  • 7-bit addressing: the 7-bit addressing system used by the I²C protocol is insufficient to prevent address collisions between devices. 10-bit addressing can partly mitigate this issue, but it is not widely supported.

I2C applications

Today, the I²C protocol is mostly used for low-speed peripheral connections where affordability and economy of space are prioritized over data transfer rate. It excels in simple multi-master applications.

  • Accessing electrically erasable programmable read-only memory (EEPROM)

  • Accessing low-speed digital-to-analog converters (DACs) and analog-to-digital converters (ADCs)

  • Accessing real-time clock signals and non-volatile random-access memory (NVRAM) chips

  • Reading hardware sensors

  • Adjusting volume in speakers

  • Adjusting monitor settings

  • Controlling power supply

Recommended reading: The life of Pi: Ten years of Raspberry Pi

What is the SPI protocol?

SPI protocolThe four signal lines of the SPI protocol

SPI (Serial Peripheral Interface) is a serial communication protocol that is mostly used for short-distance data transmission in embedded systems. 

Developed in 1979 by telecommunications company Motorola, the SPI protocol is still widely used today, with some of its most significant uses being communication with Secure Digital (SD) cards — those found in digital cameras, for instance — and liquid crystal displays (LCDs). 

SPI is a full-duplex communication protocol, which means it can communicate in two directions simultaneously. This is one of the key distinctions between SPI and I²C, which is a half-duplex system.

Typically using a single master device, the SPI protocol has four signal lines, twice that of the I²C protocol:

  1. SCLK (serial clock): output from master

  2. MOSI (master out slave in): data output from master

  3. MISO (master in slave out): data output from slave

  4. CS/SS (chip/slave select): output from master to indicate data being sent

Accordingly, the physical SPI bus uses four wires. Because of the push/pull drivers used with SPI, the protocol can transmit data at a fast rate.

SPI advantages

The SPI protocol has several advantages, both over the comparable I²C protocol and more advanced parallel communication protocols.

  • Push-pull drivers: as opposed to open drain, the push-pull drivers provide high speed data transfer — higher than I²C — as well as good signal integrity.

  • Versatility: communication can take various forms, with total flexibility in terms of message size and content.

  • Simplicity: although it requires twice as many pins as an I²C bus (which is still fewer than parallel communication systems), SPI requires minimal circuitry and uses less power than I²C.

SPI limitations

Despite its good speed, versatility, and simple hardware interfacing, SPI has a few important limitations.

  • Single master: the SPI protocol is typically limited to a single master device, though there are exceptions to this rule.

  • No formal standard: SPI is a de facto standard. In other words, it is not formalized, which means each device defines its own protocol. Documentation can be difficult to obtain and navigate.

  • Four pins: an SPI bus has a larger topology than an I²C bus, though it is still smaller than most parallel communication buses.

SPI applications

The SPI protocol is today most commonly used for short-distance communication in embedded systems. However, it still serves a fairly broad range of applications.

  • Accessing electrically erasable programmable read-only memory (EEPROM) and flash memory

  • Accessing digital-to-analog converters (DACs) and analog-to-digital converters (ADCs)

  • Accessing real-time clock signals

  • Reading hardware sensors

  • SD cards and MMCs

  • LCD screens

I2C vs SPI summary

Using serial communication protocols and buses instead of parallel buses delivers limited performance but can reduce component costs, space, and power consumption.[2] Both I²C and SPI are therefore highly useful for many peripheral connections, especially in integrated devices.

Of course, the two protocols have important differences, and choosing between them depends on the application.

One of the key reasons to choose I2C vs SPI is the slenderness of I²C: the bus uses minimal pins, making it easy to build an I²C network. Furthermore, despite its simplicity, it offers important features like multi-master conflict handling and addressing management. Generally, I²C beats SPI when it comes to multi-master applications.

But SPI has its own distinct uses which can make it a better choice than I²C — typically for the fast transfer of data streams between SPI devices. It is fast and offers full-duplex communication, in addition to SPI communication being much more versatile than I²C communication in terms of message purpose, content, and size.

Neither I²C nor SPI are a suitable replacement for a high-performance protocol like USB (universal serial bus) or firewire; however, their compactness and efficiency make them essential to many peripheral connection applications.

Recommended reading: SPI vs I2C vs UART: In-Depth Comparison


I2C

SPI

Developer

Philips

Motorola

Type

Half-duplex communication

Full-duplex communication

Speed(s)

100 kbps, 400 kbps, 3.4 Mbps

10 Mbps+

Signal lines

2

4

Masters

Multiple

Typically one

I2C to SPI conversion

As the two serial communication protocols have similarities, some developers have attempted to develop a protocol conversion unit that could facilitate communication between one device using I²C and another using SPI.

Researchers from the K.J. Somaiya College of Engineering have developed such a conversion unit that can take data from a sender device working on the SPI protocol and send it to a receiver device working on the I²C protocol.

The researchers did this in order to send commands and data to a peripheral device using the “high speed of SPI” while simultaneously being able to “save on dedicated pins for each peripheral device using a rather simple two-wire interface of I2C,” thus maximizing the respective strengths of each protocol.[3]

However, use of such a conversion unit is not widespread, with most users choosing one protocol or the other and sacrificing one set of benefits.

Recommended reading: PWB vs PCB: Differences and Similarities

References

[1] Mankar J, Darode C, Trivedi K, Kanoje M, Shahare P. Review of I2C protocol. International Journal of Research in Advent Technology. 2014 Jan;2(1).

[2] Hanabusa R. Comparing JTAG, SPI, and I2C. Spansion’s application note. 2007 Apr:1-7.

[3] Trivedi D, Khade A, Jain K, Jadhav R. SPI to I2C protocol conversion using verilog. In2018 Fourth International Conference on Computing Communication Control and Automation (ICCUBEA) 2018 Aug 16 (pp. 1-4). IEEE.

More by Umar Waseem

Umar is an electrical engineering graduate with a strong technical background in Robotics, IoT, Industrial Process and Control, Embedded Systems, Power Electronics, and Electronic Network Analysis. In addition to his electronic troubleshooting expertise, he has a passion for writing and consistently...