Arduino and SPI Interface

SPI, or Serial Peripheral Interface is a full-duplex serial protocol for communicating with high-speed peripherals, such as microcontrollers. You can communicate with SPI devices and sensors via SPI interface on Arduino® boards using MATLAB® Support Package for Arduino Hardware. You can also use this interface to communicate between two microcontrollers. Typically, SPI devices have one master device that controls all peripheral devices. The SPI library has three common pins that are hardwired and a dedicated pin for output.

  • MISO, receives data from the SPI peripheral device

  • MOSI, which outputs data to the SPI peripheral device

  • SCLK, which outputs a serial clock signal to synchronize communications

  • CE, which enables and disables peripheral devices from the master

Note

To create a custom SPI code, see Create Custom Arduino Add-On Device, Library, or Code

Every SPI device implements SPI standards differently. Refer to the device datasheet to understand how your device will work. SPI Devices transmit data in four basic modes and control the clock phase and the clock polarity. For more information refer to the SPI standards documentation.

For more information on Arduino SPI devices, see https://arduino.cc/en/Reference/SPI.