Attaching an SD (SPI) and Screen (SPI) to Photon

I had a hard time getting an SD card to work with the Photon. But using the following settings/pins worked fine:

#define SPI_CONFIGURATION 1

#elif SPI_CONFIGURATION == 1
// Secondary SPI with DMA
// SCK => D4, MISO => D3, MOSI => D2, SS => D5 (changed from D1)
SdFat sd(1);
//const uint8_t chipSelect = D1;
const uint8_t chipSelect = D5; //<-------------------- Use D5

I plan to use the following 1.3" SPI screen from Adafuit

I know that the Photon has two hardware SPIs so I would appreciate the community's help in selecting the correct pins on the Photon for screen connection.

OLED

Thanks in advance.

https://docs.particle.io/reference/firmware/photon/#spi

When you know that SPI MOSI means Master Out Slave In you can probably guess that this would make most sense to be connected to Data.
Similarly since SCK stands for SPI ClocK it's an easy guess too.
Next obvious choice would be SS meaning Slave Select while CS means Chip Select and hence they seem to match quite nicely.
So you are now left with DC & RST and since these are not SPI specific, you can choose whatever pin you have free.

BTW, there was another thread down a very similar request you might want to look into

Also mentioned in that thread, you can have multiple devices on the same SPI port.
It's easiest when all devices share the same SPI mode, but that's not compulsory.

Thank you very much @ScruffR. It is very clear now.

Hello @ScruffR,

May I used A4 for DC?

Thanks in advance.

Yes. A4 can be used as a digital output to work with the display’s DC pin.

1 Like

Thank you.