T-Display-S3 (touch version) trouble to connect SD card reader (SPI)
-
Hi,
I try to connect a SD reader via SPI to the T-Display-S3 touch version - sadly without success.
From reading other comments/websites it seems I can freely define the pins for a secondary (HSPI) SPI bus.
This is what I tried:#include "FS.h" #include "SD.h" #include "SPI.h" SPIClass spiSD(HSPI); #define SDSPEED 27000000 // SPI port #2: SD Card Adapter #define SD_CLK 21 //yellow #define SD_MISO 18 //brown #define SD_MOSI 17 //orange #define SD_CS 16 //green
in setup I have:
Serial.begin(9600); spiSD.begin(SD_CLK, SD_MISO, SD_MOSI, SD_CS); //SCK,MISO,MOSI,cs if (!SD.begin(SD_CS, spiSD, SDSPEED)) { Serial.println("Card Mount Failed!"); return; } else { Serial.println("Card Mount Successful!"); }
but all I get is "Card Mount failed" - I have multiple reader modules, but I get the same result with all of them, so i assume the issue is with my setup/pins/code...
any help would be highly appreciated - thanks in advance
-
I found the solution on my own with some help of Google.
In the end I only had to add one more line of code to make it work (switching the CS Pin to output...):pinMode(SD_CS,OUTPUT);
so the complete code-part looks like this:
void setup() { Serial.begin(9600); spiSD.begin(SD_CLK, SD_MISO, SD_MOSI, SD_CS); //SCK,MISO,MOSI,cs pinMode(SD_CS,OUTPUT); if (!SD.begin(SD_CS, spiSD, SDSPEED)) { Serial.println("Card Mount Failed!"); return; } else { Serial.println("Card Mount Successful!"); } }