Help with micro sd

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
}

D_NQ_NP_902170-MCO41231061350_032020-O

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
}

D_NQ_NP_902170-MCO41231061350_032020-O

I've merged your duplicate post. Please do not cross post.

Yes, it was a mistake, it wasn't on purpose.

can you try with SdFat - Arduino Reference

if you don't care about what's on the SD card, start with the SdFormatter example

What size SD card. The SD library is limited to 32G maximum.

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.

Just in case this helps ...

Yes, that module feeds its Vcc pin to a built-in 3.3V regulator. So it needs 5V at Vcc.

16
on arduino it works but on esp it doesn't

siempre a estado conectado a 5v
on arduino it works but on esp it doesn't, thanks for your help

Stop messing about with that uSD board.
Get one of these (3V) --

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.