Closed wieb18 closed 5 years ago
Finally.... it works.... :
Change SD.h library with mySD.h library from https://github.com/nhatuan84/esp32-micro-sdcard.
#include <SPI.h>
#include <mySD.h>
File root;
const int chipSelect = 13;
void setup()
{
Serial.begin(115200);
Serial.print("Initializing SD card...");
pinMode(SS, OUTPUT);
//SDClass::begin(uint8_t csPin, int8_t mosi, int8_t miso, int8_t sck)
if (!SD.begin(13, 15, 2, 14)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
root = SD.open("/");
printDirectory(root, 0);
Serial.println("done!");
}
void loop()
{
// nothing happens after setup finishes.
}
void printDirectory(File dir, int numTabs) {
// Begin at the start of the directory
dir.rewindDirectory();
while(true) {
File entry = dir.openNextFile();
if (! entry) {
// no more files
//Serial.println("**nomorefiles**");
break;
}
for (uint8_t i=0; i<numTabs; i++) {
Serial.print('\t'); // we'll have a nice indentation
}
// Print the 8.3 name
Serial.print(entry.name());
// Recurse for directories, otherwise print the file size
if (entry.isDirectory()) {
Serial.println("/");
printDirectory(entry, numTabs+1);
} else {
// files have sizes, directories do not
Serial.print("\t\t");
Serial.println(entry.size(), DEC);
}
entry.close();
}
}
Conclusion, nothing wrong with SD Card GPIO print on the back of the board.
The root of this issue cause by SD.h library which unable to detect TTGO SD card because it used custom CS, MOSI, MISO, SCK sequence.
It also works with the standard SD library:
#include <SPI.h>
#include <SD.h>
#define SD_CS 13
void setup()
{
SPI.begin(14, 2, 15, 13);
Serial.begin(115200);
SD.begin(SD_CS);
if (!SD.begin(SD_CS)) {
Serial.println("Card Mount Failed");
return;
}
uint8_t cardType = SD.cardType();
if (cardType == CARD_NONE) {
Serial.println("No SD card attached");
return;
}
Serial.println("Initializing SD card...");
if (!SD.begin(SD_CS)) {
Serial.println("ERROR - SD card initialization failed!");
return; // init failed
}
}
I just bought TTGO T8 V1.1 board.
The board comes with installed "Hello World" and SD Card initialization sketch. It prints "Hello World" text and shows SD card files list in Serial Monitor when turn on for the first time. So, the SD card works fine.
The problem is now I can't make SD card works anymore.
https://ae01.alicdn.com/kf/HTB1laFLXinrK1Rjy1Xcq6yeDVXaf.jpg
Board picture says the SD card CS Pin is GPIO 13 but doesn't work. Already tried changing CS pin to GPIO 2, 4, 14, 15 but also doesn't work.
Anybody knows how to enable TTGO T8 SD card?
Thanks.