Micro SD module is not getting recognised by esp32

Im trying to make my micro sd module connect to esp32, to make a file for sensor data processing. The thing is i dont know why is not working, i used a tester to measure the input signal and its getting 3.3V. This is my code and pin setup. I tried changing the Vcc pin to the esp Vin pin but that also made no effect.

 #include "SD.h"
#include "SPI.h"

File archivo;

void setup() {
  Serial.begin(9600);
  delay(2000);

  if (!SD.begin()){
    Serial.println("Error en módulo SD");
    return;
  }

  uint8_t cardtype = SD.cardType();

  if(cardtype == CARD_NONE){
    Serial.println("No hay ninguna memoeria conectada");
    return;
  }

  Serial.println("Modulo SD inicializado");
  archivo = SD.open("/prueba.csv", FILE_WRITE);
  archivo.println("QUE CAPA QUE SOY");
  archivo.close();
  Serial.println("Ya lei");
  ; 

  if(!archivo){
    Serial.println("Error al crear archivo");
    return;
  }
}

void loop() {
}

pines
VCC -> pin 1 (3.3V)
GND -> pin 38
MISO -> GIOP 19
MOSI -> GIOP 23
SCK -> GIOP 18
CS -> GIOP5

This is my first project working with both, so i would really aprreciate your help!

It does work, but the code isn't quite right.
If you close the file, you can't check if it's open later. Of course, it isn't.
Try this.

#include "SD.h"
#include "SPI.h"

File archivo;

void setup() {
  Serial.begin(9600);
  delay(2000);

  if (!SD.begin()){
    Serial.println("Error en módulo SD");
    return;
  }

  uint8_t cardtype = SD.cardType();

  if(cardtype == CARD_NONE){
    Serial.println("No hay ninguna memoeria conectada");
    return;
  }

  Serial.println("Modulo SD inicializado");
  archivo = SD.open("/prueba.csv", FILE_WRITE);
  if (archivo) {
    archivo.println("QUE CAPA QUE SOY");
    archivo.close();
    Serial.println("Ya lei");
  } else {
    Serial.println("Error al crear archivo");
    return;
  }
}

void loop() {
}

A question: why didn't you ask in the Spanish forum? (Me lo hacías más fácil) :wink:

1 Like

And which module, exactly, would that be? It is a bare breakout board, or is it one of the common generic modules intended to interface with 5V logic rather than the 3.3V levels of your ESP32? You can see what you using; we can't.

Yes you are right sorry! In my country is the only one available, its a common generic one, but it says range of input voltage. 3.3-5V

And in my country, there are many different types available. So I still have no idea which one of those it might be that you are using.

Good luck with your project.

1 Like

It worked thank you so much!!! (no sabia que habia foro en español jajajaja)

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