
Description
Hi all, I have just purchased a LoLin32 Pro for a home project where I need to log some data to an SD card. I am trying to initialise a Micro SD card through the onboard Micro SD slot using the SD library functions but cannot get the card to work. On a previous project, I have had the SD card work on the LoLin32 through a Wemos Micro SD shield with no problems so the SD card is fine, but it won't initialise when used in the SD card slot for the LoLin32 Pro.
The set up of the board is quite literally just the micro sd card, inserted into the micro sd card slot and then the board connected to the USB cable.
Here is the portion of my code that is responsible for initialising the micro SD card.
`#include <SD.h>
#include <SPI.h>
#define CS 13
File dataFile;
void setup() {
Serial.begin(9600);
setUpSD();
}
void loop() {
// put your main code here, to run repeatedly:
}
void setUpSD() {
Serial.print("\n\n");
//Tell user to insert SD card
Serial.println("Please insert SD card");
while(!SD.begin()) {
}
Serial.println("SD card present");
if(SD.exists("/dataLog.txt") != true) {
dataFile = SD.open("/dataLog.txt", FILE_WRITE);
dataFile.print("\n");
dataFile.close();
Serial.println("File 'dataLog.txt' created");
} else {
Serial.println("File 'dataLog.txt' already exists");
}
}
When I upload it all I receive on the serial monitor is 'Please insert SD card' and then it gets stuck in the while loop.
I even tried using the examples sketch from the esp32 library for the SD card for esp32 but that doesn't work either, it just tells me that the 'card mount has failed', which is the response it gives if SD.begin() returns false.
Here is the schematic for the LoLin32 Pro as well.
Any help as to why SD.begin() won't work will be greatly appreciated.
Thanks!