42. SPI vs I2C Speed Comparison

Create a task where a Master Arduino UNO sends 100 KB of data to a Slave Arduino UNO using I2C first and then SPI respectively.

  • The master will print the time consumed for both communication methods.
  • A slave will print the number of data bytes received by both communications. 

NOTE:  The string of 1KB of data is given below, send it 100 times for 100 KB of data.

Data String 

“I2C (Inter-Integrated Circuit) & SPI (Serial Peripheral Interface ) are two common communication protocols used to connect devices like sensors and microcontrollers. I2C uses two lines: SDA (data) and SCL (clock), allowing multiple devices to communicate through unique addresses. It supports multi-master and multi-slave configurations but operates at a slower speed, typically 100kHz to 400 kHz, though it can reach higher speeds in fast modes. I2C is simple and requires fewer connections, but its clock stretching and overhead make it less efficient for high-speed data transfers. SPI, on the other hand, use four lines: MOSI (Master Out Slave In), MISO (Master In Slave Out), SCK (clock), and SS (Slave Select). SPI supports higher speeds (up to tens of MHz), making it better suited for fast data transfers. It's simpler in protocol, with no need for addressing, but it requires more wires and separate SS lines. While I2C is ideal for many devices, SPI excels in fast, reliable communication.”

Expected Output

 


 

Submit Your Solution