I2C vs SPI: What do you pick, and why?

Hi All,

So I’ve done my fair share of research on the pros and cons of using I2C vs SPI, but I want to know what other Arduino users use each for, and why. To my understanding, I2C can be significantly slower than SPI, but its best feature is how many devices you can have connected to it with so few pins. So how do you utilize each bus?

Right now I have three I/O expanders on the SPI that read six digital pins and control six RGB LEDs. I’ve just begun planning to adapt my project to read four potentiometer knobs (A0 - A3) and read/write to an external EEPROM, which I’m considering to do via I2C. I’m wondering if I should also consider running the EEPROM off of SPI, although I figure that may be more trouble than its worth. I know that there are also I/O expanders for I2C, so I’m wondering what do you do in similar situations? Any guidance on how I should approach these types of decisions? Thanks in advance,


As you say SPI is quicker than I2C but needs at least 3 (but normally 4) pins and for every extra SPI device you add you need an extra chip select pin. I2C only needs 2 pins and you can connect several devices to the same 2 pins as long as each device has a different I2C address. A lot of I2C devices have the ability to change the address within a small range so if you need more than one of the same device you can put them on different addresses.

Everybody will have there own reasons for using either SPI or I2C but for me, apart from the obvious thing of a device only supporting either I2C or SPI I would pick SPI for things that need to move a lot of data and do it quickly (SRAM, FRAM, EEPROM, TFT displays). I2C is more convenient for small amounts of data and/or reduced pin count, things like RTC, Temperature sensors, LCD etc.

In addition to what Riva wrotes, I2C has an additional advantage: You can connect 3V3 and 5V devices on the same bus without the need for a level converter. That's because the master as well as the slaves are not actively supplying a high state but only pulls the data signal to ground if necessary while a pull-up resistor pulls the signal high if no bus member is pulling it down. A level of 3V3 is a HIGH level for almost all 5V devices so you won't get problems connecting both types of devices to the same bus.

Both (SPI and I2C) are limited to a short bus length (about half a meter) without additional precautions but the I2C bus is extended more easily if that's necessary.