Difference between I2C and SPI
What you will learn here about I2C vs SPI:
- Difference between I2C and SPI
- How to choose between SPI and I2C
Difference between I2C and SPI
Parameter | I2C | SPI |
---|---|---|
Full Form | I2C stands for Inter integrated circuit | SPI stands for Serial peripheral interface |
Number of wires | I2C requires 2 wires (SCL and SDA) | SPI requires 4 wires (MISO, MOSI, CS and CLK) |
Connection diagram | ||
Communication | I2C is half duplex communication means master and slave can talk with each other but not simultaneously. | SPI is full duplex communication means master and slave can talk with each other simultaneously |
ACK | I2C gets Acknowledgement from respective slave after every transmission means I2C gives guarantee of data transmission. | SPI doen't get any acknowledgement from the slave device means SPI does not give guarantee of data transmission. |
Mechanism | I2C uses Addressing mechanism to communicate with respective slave. | SPI uses slave select or chip select pin to communicate with respective slave. |
Multiple slaves or Scale | Only two wires are enough to communicate with multiple slaves since it supports addressing mechanism. | SPI requires one chip select or slave select pin per slave. So as number of slaves increasing, number of slave select or chip select pins also increases. |
Speed | I2C is Slower(typically 100kbps, 400kbps and 3.4Mbps) | SPI is Faster (upto 10 Mbps) | Power | I2C requires more power | SPI requires less power |
Distance | I2C Can be used for long distance | SPI Better for short distance |
How to choose between SPI and I2C
We all know about I2C and SPI but we always have a question, how to choose between SPI and I2C right!When to use SPI
SPI is a better choice when1)when you want to send data with higher speed.
When to use I2C
I2C is a better choice when1)you want reliable data transmission since it supports acknowledgment mechanism.
2)Only two wires/ pins require to communicate with multiple slaves. SPI requires the number of slaves equals to the number of slave select wires or number of pins. So I2C is a better choice when you have a limited number of pins.