(micro card adapter modue with esp32)error opening test.txt/cannot writning file on micro sd card

hi there...i was search on google to solve this problem,,i was read all solution for it.but i dont know,i think all the solution im still dont understand.
this is schematic project:
but in this project i use micro sd card adapter,and this is pin layout from the sd card adapter:
I've checked every pin I installed is correct.like this image:

why i change input voltage to 5v?,because before the voltage input ive given is 3.3 v but "initialization failed!" in serial monitor.and after i change input power with 5v ,it has done "initialization done." but a new problem appears here that esp32 is not wanting to write to the sd card.i also cheked my sd card into my computer,and there is no file on there..
massage on serial monitor:

this is my code:

#include <SPI.h>
#include <SD.h>
File myFile;
void setup() {
// Open serial communications and wait for port to open:
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
Serial.print("Initializing SD card...");
if (!SD.begin(5)) {
Serial.println("initialization failed!");
while (1);
Serial.println("initialization done.");
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
myFile = SD.open("test.txt", FILE_WRITE);
// if the file opened okay, write to it:
if (myFile) {
Serial.print("Writing to test.txt...");
myFile.println("This is a test file :)");
myFile.println("testing 1, 2, 3.");
for (int i = 0; i < 20; i++) {
// close the file:
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
void loop() {
// nothing happens after setup

anyone know how to solve this problem?

Your SD module is designed for 5 V systems,
I doubt you will have much fun with it on a 3.3 V system.

SD cards use 3.3 V, so the cheapest modules without any electronics should work better.

1 Like

but my esp32 still couldnt write on sd card.

I have the impression that you are not listening.

There is a 5 V to 3.3 V level shifter, shifting your 3.3 V MOSI signal from 5 V to 3.3 V.
I doubt that this will work reliably.

so i have to powering mosi,sck,cs with 3.3v? ive test output voltage on cs=3.2v,sck=0v,mosi=0v. and miso 3.2v. vcc=5v. so ive powering sck and mosi with 3.3vdc ? i know these module have shifter 5v to 3.3v. but it does mean ive powering 0v sck and mosi?

I'm sorry that you don't want the message,

but your adapter / MPU combination will not work reliably, whatever you would try.

so what is the solution for??...i watching any tutorial on youtube and its work fine,but i try to search on google i dont get the truth answer for those problem..what should i do now?

Use a different adapter without level shifter, or a ESP32 board with am integrated micro-SD card slot.

Any recommendations for adapter brands that work well? because i dont find any adapter sd card module without shifter yet,

i think all adapter module sd card have shifter

Any just mechanical contacting holder would work,
I've even seen a setup with wires soldered to the card.

This module only has capacitors and safety resistors.

Or this, absolutely bare

thanks a lot brother... :slight_smile:

I'm sorry that you bought the wrong adapter, I have some of those too.
They are nasty, they don't release MISO, even when deselected without hardware modification.
They like to be alone on the SPI bus.