Maximum number of SPI devices

Hello everyone
I would appreciate the community’s help on finding out the maximum umber of SPI devices that ca be connected to a Photon?

For example, can I have both an SD card and an SPI screen?

Thanks.

Yes. You can have both devices on the same SPI bus… As long as each device has a Chip Select (CS) pin. Each device needs a dedicated Photon GPIO pin for the CS. I don’t know of a theoretical limit to the number of SPI devices… You usually run out of GPIO pins for CS first but you can use GPIO expander to add more.

1 Like

Also be aware that some “SPI” devices don’t fully adhere to the standard and may not tri-state their data pins or keep silent when not selected, potentially causing issues. But the bus should support many concurrent devices.

2 Likes

This is true. For others that want to run many SPI devices with IC’s that issues like @ScruffR mentioned there are many SPI multiplexers IC’s on the market like this on that will disconnect all lines from one to another.
https://www.analog.com/en/products/adgs1409.html?doc=ADGS1408-1409.pdf#product-overview

2 Likes

Also, not every device uses the same SPI mode and speed settings. Often, device libraries don’t play nice with other libraries (eg. SD libraries and OLED or TFT libraries). This is why Arduino (and Particle) introduced the SPIsettings() object to set the SPI bus parameters before any transaction.

1 Like