Hey there I was recently working on a project with my ESP-32 and my SSD1306 OLED Display and when I connected a microSD card module to the ESP-32s SPI pins SD.begin returns false.
Furthermore, my OLED isn't displaying what it should and is just displaying random noise.
Almost all microSD modules (except Adafruit's) that have onboard level shifters suffer from a circuit design flaw which leaves the MISO line active even when the device's CS line is not enabled. So the module works fine by itself, but interferes with any other SPI devices that are present.
However, while that would explain why the display would malfunction when the SD module is present, it wouldn't explain why the SD would not initialize properly. Well, unless the display suffers from the same fault, which is unlikely. So I think the first step is to test the SD card with the display disconnected. Run the CardInfo example in the library just to be sure you have the wiring right, and are using the right pin for CS. If that works, then reconnect the display and see if CardInfo still works.
Power issues can also be a problem.
Could you post a link to, or picture of, your SD module? Also, if your card is SDXC or higher, does your library support that? And maybe post a drawing of how the module's power is provided.
Indeed my microSD module comes with onboard level shifters, however when I plugged it alone to my Arduino UNO and ran the example code "CardInfo", it failed to initialize. Also, my OLED Display uses I2C, not SPI so that could not be a reason for it failing to work. Furthermore, I have tested all of my female-to-male jumper wires which I have used to connect my microSD card module to my Arduino and they all seem to work just fine. Here's a picture of my module if it helps:
If you are using the same CS pin that's defined in the CardInfo example, and if you have a solid 5V going to the module's Vcc pin, and if your SD card is SD or SDHC, then it ought to work. I'm assuming you formatted the card as FAT32.
When you switch back to the ESP32, you will still need to power the module with 5V.
Indeed I have everything connected right to my microSD Card Module with my Arduino. However, it doesn't work even on the Arduino which provides a stable 5V. I do not think it's a technical fault with the module as it is brand new and provided by a trusted supplier. My microSD-HC is formatted with FAT-32 and all of the wires are connected to the right spots, but I am still confused as to why it is not working.
Well, when we get to this point here, the final answer usually ends up being one or more of the following:
The wiring is actually not hooked up right, the problem usually being the CS line being connected to a pin that's different from what the sketch says.
One or more of the jumper wires is actually open.
In rare cases, the sketch may need additional delay before trying to access the card to allow for the card's controller to boot up.
But in the end, if the module is good, and the card is good, and wiring is correct, and power is sufficient, and the software is known to be correct, and it still doesn't work, then you must be under an evil spell.
Ok I got it to initialize and it detects my card as SDHC which is correct. But it says it can't find a FAT32 partition even though there is only one partition and it is FAT32.
For those reading this in the future, the reset button solution may mean that the SD card's controller needs more time to boot up before attempting to communicate with it.
Also, the SdFat.h library has a card formatting example that's better than the sdcard.org formatting tool. It actually erases the entire card before formatting it, which may speed up all writes to the card since the sectors don't have to be erased before writing to them. The official formatting tool can't do that. Its overwriting option is actually the worst thing to do since it leaves no sectors erased.