I need to program communication between raspberry pi 3 and microcontroller. I'm wondering what type of communication is the Best. I2C, UART or SPI?

  • uart is easy and best. – tlfong01 Aug 6 '19 at 9:57
  • 1
    It's like asking what is best between an apple, an orange and a carrot. – Dmitry Grigoryev Aug 6 '19 at 12:15

I2C: Inter-Integrated Circuit, used for communicating between chips on the same PCB. Allows multi-master, multi-slave configuration, slower than SPI. This is a two-wire bus. No two devices can have the same slave address on a single bus.

SPI: Serial Peripheral Interface, used for communicating with external devices (chips, sensors, displays etc). Much faster than both UART and I2C. Provides single master, multi-slave configuration. Each slave must have its own Chip Select pin, so typically, the number of devices attached is limited to the number of IO pins you have available.

UART: Traditional serial communication between two devices. Slower than I2C and SPI, but can be used over long(er) distances. Typical use is between two devices (PC and microcontroller for example).


It depends on the microcontroller and what purpose you need out of it. However, most microcontrollers use ICSP or serial UART as a programming interface. Therefore, at the minimum, you would need UART.

UART is also trivial to implement in most DIY programs. In most cases, you will simply need to read and write strings to an interface (e.g. \dev\ttyX on RPi, Serial.write() on Arduino).

I've only ever encountered other protocols, like I2C and Dallas OneWire, when interfacing with sensors.

Not the answer you're looking for? Browse other questions tagged or ask your own question.