I am currently trying to make a micro SD module work with an esp32 devkit v1 but it has problems, the board has correct connections, the micro SD is in FAT32 and the Arduino IDE code does not detect problems in the code, the code loads correctly , the esp32 detects the correct operation of the module by printing "correct initialization" on the serial monitor since a part of the code indicates that if the module works it prints this message but when trying to create a document called "data.txt" it cannot be created. Making it print a message indicating that no document has been created, I connect the SD to the PC and there is actually nothing, is something missing from the code, is the library not compatible with ESP or what is the problem?
#include <SPI.h> // incluye libreria interfaz SPI
#include <SD.h> // incluye libreria para tarjetas SD
#define SSpin 5 // Slave Select en pin digital 10
File archivo; // objeto archivo del tipo File
void setup() {
Serial.begin(9600); // inicializa monitor serie a 9600 bps
Serial.println("Inicializando tarjeta ..."); // texto en ventana de monitor
if (!SD.begin(SSpin)) { // inicializacion de tarjeta SD
Serial.println("fallo en inicializacion !");// si falla se muestra texto correspondiente y
return; // se sale del setup() para finalizar el programa
}
Serial.println("inicializacion correcta"); // texto de inicializacion correcta
archivo = SD.open("prueba.txt", FILE_WRITE); // apertura para lectura/escritura de archivo prueba.txt
if (archivo) {
archivo.println("Probando 1, 2, 3"); // escritura de una linea de texto en archivo
Serial.println("Escribiendo en archivo prueba.txt..."); // texto en monitor serie
archivo.close(); // cierre del archivo
Serial.println("escritura correcta"); // texto de escritura correcta en monitor serie
} else {
Serial.println("error en apertura de prueba.txt"); // texto de falla en apertura de archivo
}
archivo = SD.open("prueba.txt"); // apertura de archivo prueba.txt
if (archivo) {
Serial.println("Contenido de prueba.txt:"); // texto en monitor serie
while (archivo.available()) { // mientras exista contenido en el archivo
Serial.write(archivo.read()); // lectura de a un caracter por vez
}
archivo.close(); // cierre de archivo
} else {
Serial.println("error en la apertura de prueba.txt");// texto de falla en apertura de archivo
}
}
void loop() { // funcion loop() obligatoria de declarar pero no utilizada
// nada por aqui
}
I am currently trying to make a micro SD module work with an esp32 devkit v1 but it has problems, the board has correct connections, the micro SD is in FAT32 and the Arduino IDE code does not detect problems in the code, the code loads correctly , the esp32 detects the correct operation of the module by printing "correct initialization" on the serial monitor since a part of the code indicates that if the module works it prints this message but when trying to create a document called "data.txt" it cannot be created. Making it print a message indicating that no document has been created, I connect the SD to the PC and there is actually nothing, is something missing from the code, is the library not compatible with ESP or what is the problem?
#include <SPI.h> // incluye libreria interfaz SPI
#include <SD.h> // incluye libreria para tarjetas SD
#define SSpin 5 // Slave Select en pin digital 10
File archivo; // objeto archivo del tipo File
void setup() {
Serial.begin(9600); // inicializa monitor serie a 9600 bps
Serial.println("Inicializando tarjeta ..."); // texto en ventana de monitor
if (!SD.begin(SSpin)) { // inicializacion de tarjeta SD
Serial.println("fallo en inicializacion !");// si falla se muestra texto correspondiente y
return; // se sale del setup() para finalizar el programa
}
Serial.println("inicializacion correcta"); // texto de inicializacion correcta
archivo = SD.open("prueba.txt", FILE_WRITE); // apertura para lectura/escritura de archivo prueba.txt
if (archivo) {
archivo.println("Probando 1, 2, 3"); // escritura de una linea de texto en archivo
Serial.println("Escribiendo en archivo prueba.txt..."); // texto en monitor serie
archivo.close(); // cierre del archivo
Serial.println("escritura correcta"); // texto de escritura correcta en monitor serie
} else {
Serial.println("error en apertura de prueba.txt"); // texto de falla en apertura de archivo
}
archivo = SD.open("prueba.txt"); // apertura de archivo prueba.txt
if (archivo) {
Serial.println("Contenido de prueba.txt:"); // texto en monitor serie
while (archivo.available()) { // mientras exista contenido en el archivo
Serial.write(archivo.read()); // lectura de a un caracter por vez
}
archivo.close(); // cierre de archivo
} else {
Serial.println("error en la apertura de prueba.txt");// texto de falla en apertura de archivo
}
}
void loop() { // funcion loop() obligatoria de declarar pero no utilizada
// nada por aqui
}
I'm not sure if this is your problem but I had similar problems some time ago. I solved it by connecting VDD to 5V instead of 3V3, it looks like 3V3 is not enough to power the SD card.