Hi, I am facing a problem when using the hardware : esp32, rfid reader and a tft display with an sd card reader builtin. The rfid demands the use of the spi, and it seems internally the sd card also uses it, the problem is that when we enable it the sd card unmounts, example :
#include <SPI.h>
#include <FS.h>
#include <SD.h>
#include <TFT_eSPI.h>
#include <MFRC522.h>
#include <JPEGDecoder.h> // JPEG decoder library
MFRC522 rfid(21, 4);
MFRC522::MIFARE_Key key;
TFT_eSPI tft = TFT_eSPI();
void setup() {
Serial.begin(115200);
digitalWrite(22, HIGH); // Touch controller chip select (if used)
digitalWrite(TFT_CS, HIGH); // TFT screen chip select
digitalWrite( 5, HIGH); // SD card chips select, must use GPIO 5 (ESP32 SS)
tft.begin();
if (!SD.begin(5, tft.getSPIinstance())) {
Serial.println("Card Mount Failed");
return;
}
doFile( "/lena20k.jpg" );
delay(4000);
SPI.begin(); // <<<------- after this line, the sd card is unmounted for some reason :(
doFile("/lena20k.jpg");
}
void doFile( const char *filename ) {
File jpegFile = SD.open( filename, FILE_READ); // Open the named file (the Jpeg decoder library will close it) or, file handle reference for SD library
if ( !jpegFile ) {
Serial.print("ERROR: File \""); Serial.print(filename); Serial.println ("\" not found!");
} else {
Serial.print("File found :\""); Serial.println(filename);
}
}
void loop() { }
Did anyone face something like this ? And have a solution other then reading everything you need and put in memory ?