Questions tagged [spi]

Serial Peripheral Interface. Allows full-duplex serial communication from a master device to one or more slave devices arranged on a bus. Sometimes referred to as a 4-wire bus.

SPI (Serial Peripheral Interface) is used to communicate bi-directionally with other peripherals. The SPI interface normally has the following signals:

  • SCK - serial clock, sometimes called CLK - this provides the clock data which controls the rate of data transfer
  • MOSI - Master Out, Slave In, sometimes called DO (Data Out) - this is the data from the master to the slave
  • MISO - Master In, Slave Out, sometimes called DI (Data In) - this is the data from the slave to the master
  • SS - Slave Select - when asserted the slave knows it is being communicated with. When SS is not asserted the slave keeps all signals at high-impedance, so other devices can use the same SCK/MOSI/MISO lines.

The signals SCK/MOSI/SS are outputs on the master end. The MISO signal is an output on the slave side, if SS is asserted.

The signals SCK/MOSI/MISO can be shared between multiple peripheral devices. The "active" one at a particular moment is the one which has SS asserted.


Some peripherals (eg. LED strips, output shift registers) are one-direction only. In that case the MISO signal is not used.


References

508 questions
67
votes
2 answers

How do you use SPI on an Arduino?

With reference to the Arduino Uno, Mega2560, Leonardo and similar boards: How does SPI work? How fast is SPI? How do I connect between a master and a slave? How do I make an SPI slave? Please note: This is intended as a reference question.
Nick Gammon
  • 38,901
  • 13
  • 69
  • 125
22
votes
1 answer

How to access multiple SPI interfaces on Arduino

I have worked on SPI devices connected with an Arduino one at a time. How do I work with two different SPI devices at the same time?
13
votes
3 answers

How to increase SD card write speed in arduino

I'm creating a data-logger system which logs data in SD card at a high speed of about 20000-30000 bytes per second. But the SD library in arduino currently writes data at about 4500-5000 bytes per second which is too slow. I've read this hack to…
Ashish Ranjan
  • 455
  • 1
  • 5
  • 15
11
votes
2 answers

Cheap Wired Multipoint Mesh Network

I'm looking to make a 15 x 15 grid of load sensors and RGB LEDs for an interactive dance floor. Each node will be driven by an arduino and the entire floor will be managed by a RaspberryPi. I'm trying to figure out the best way to have the nodes…
Jeremy Gillick
  • 481
  • 1
  • 3
  • 8
9
votes
1 answer

SPI Arduino Due conflict with pinMode(), bug?

Consider the following minimal example, where I set pinMode before calling SPI functions: #include void setup() { pinMode(10, OUTPUT); SPI.begin(10); SPI.setDataMode(10,SPI_MODE1); } void loop() { delay(1000); …
newandlost
  • 223
  • 1
  • 4
7
votes
3 answers

Multiple SPI device

I want to connect Ethernet board (W5100 HR911105A) to Arduino Leonardo with SPI and I also want to connect SD reader. When I test these boards separately everything working. But when I connect them on the same board the program fails at…
eszik.k
  • 121
  • 5
6
votes
3 answers

When is SPI.beginTransaction required?

I have been gradually converting many devices from i2c to spi for various reasons. I noticed in tutorials like this from arduino.cc that SPI.beginTransaction is explicitly called out. Then they link to examples such as this and this where they…
Matt
  • 205
  • 3
  • 10
6
votes
4 answers

How do I transfer more than 1 byte at once via SPI bus?

I have an AD5685R DAC that I am trying to communicate with over SPI. Per the datasheet, ...These [24] bits are transferred to the input register on the 24 falling edges of SCLK and are updated on the rising edge of /SYNC where /SYNC is used as…
Dang Khoa
  • 173
  • 1
  • 1
  • 6
6
votes
1 answer

References (e.g, libraries and tutorials) for connecting the 24-bit ADS1256 ADC to arduino

The ADS1256 chip is a high precision 24bit, 8 channel, analog digital converter based on SPI communication that is suitable for biomedical applications and perfect for sensing ECG and EEG signals. I want to hook it up to an arduino, e.g., an arduino…
mrsteve
  • 181
  • 1
  • 5
6
votes
3 answers

Crash when datalogging MPU-6050 to SD card

On an Arduino Pro Mini, I'm using Jeff Rowberg's stuff in i2cdevlib to read from the MPU6050, and using SdFat to write data to an SD card. Each part in isolation is fine, but when both DAQ and logging are in use the Arduino locks up after a few…
Craig Graham
  • 201
  • 1
  • 6
6
votes
2 answers

Using SPI without driving MISO

I am developing an application where an Arduino Pro Mini communicates with a 12-bit ADC over SPI. The communication is one-way, meaning that the ADC will only send data back to the Arduino, not receive any. The MOSI pin is therefore not required in…
Fulcrum
  • 61
  • 1
  • 4
6
votes
1 answer

Syncing/taking external clock for SPI on Arduino Due

I have an Arduino Due with a SAM3X8E chip and am trying to read SPI data from an external source that is communicating in SPI. I was able to get data by identifying specific bytes that are identifiers but realized that the clock for my board is not…
wallenut
  • 63
  • 4
6
votes
3 answers

Issue sharing MISO with multiple RC522 RFID Readers

so for about the last 8.5 hours (almost non-stop) I have been trying to figure out one issue and I have exhausted every search I could possibly think of. I'm building a puzzle that requires 5 RFID readers on the 1 Arduino, but for the sake of…
Jesse Mount
  • 61
  • 1
  • 1
  • 3
5
votes
0 answers

SPI between Master arduino and Slave arduino

How can I send the string from Slave SPI to Master SPI? I want to write code in Bare Metal. The problem which I am facing is I can't make out what will be my blocking function in Master SPI code when receiving data from slave SPI. As my SPIF bit is…
Kunal
  • 81
  • 1
5
votes
1 answer

Wrong documentation for Mega2560 SPI Pins?

This page https://store.arduino.cc/usa/mega-2560-r3 contains an image under the Documentation section which shows digital pins 10 to 13 with labels SS, MOSI, MISO, and SCK. EDIT: The documentation page has since been updated with the correct pin…
Mark
  • 197
  • 1
  • 1
  • 8
1
2 3
33 34