ESP32 Multiple Devices on SPI


I would like to use multiple devices on the SPI bus but once I initialize the SPI bus for SD card interface, using the SPI for another device (RTC) raises error that the SPI is already in use. Do I need to stop the SPI bus for the SD card first and then Start the SPI bus for the RTC? If so, how is this done, or can the SPI bus call be changed when started?

SD card call,

fatfs.mount(‘0:’, {“drv”: SPI0, “cs”: D15, “clock”: 1000000} )

RTC device call, (the error is thrown here…)

s0 = spi.Spi(D25)

I have not found any info on stopping the SPI bus or mount from the SD card. I tried mounting as NULL but did not work.


hi @bigmc777
Are you sure you are not using the same SPI driver “SPI0” for both for the SD card and the RTC.
Could you try using SPI1 for example for the RTC then initializing the SD card with SPI0.:smile: