Utilize Expansion module SD card with Arduino code
-
Re: Utilize Expansion module SD card with Arduino code
Apologies, I had originally posted in LoPy, but now I think this is really belongs here in Expansion Board. Unfortunately, I think I won't be able to be helped unless someone is willing to fire up Arduino. Please understand I can get the SD card working in MicroPython, that's just not what I'm doing here.
I am working under the assumption that the pins the Expansion Board uses for the SD card are SD: P8: DAT0, P23: SCLK and P4: CMD.
The thread in LoPy4 details how far I've gotten. Spoiler alert: not very.
tl;dr the SD_MMC sketch complains about missing pullups, and that message goes away when I start using internal pullups in my code. Yet I still cannot mount the SD card. I've tried different cards (all Sandisk Ultra - the same used successfully under MicroPython)
More detailed error logs available in the other thread using different methods - native SD, native SD_MMC and SPI
I would be incredibly grateful if someone else was willing to try to mount an SD card using Arduino.
Thanks in advance!
-
Answering my own question in case anyone else is interested in this.
Accessing the SD card on the Expansion module seems to be exclusively done with the SD_MMC library in arduino. Specifically in 1-bit mode. Internal pullups are required.
This works for me:
/* * Connect the SD card to the following pins: * * SD Card | ESP32 * D2 12 * D3 13 * CMD 15 * VSS GND * VDD 3.3V * CLK 14 * VSS GND * D0 2 (add 1K pull up after flashing) * D1 4 */ #include "FS.h" #include "SD_MMC.h" void setup(){ Serial.begin(115200); pinMode(2, INPUT_PULLUP); pinMode(4, INPUT_PULLUP); pinMode(15, INPUT_PULLUP); if(!SD_MMC.begin("/sdcard",true)){ // First arg = mount point, Second arg is 1-bit-mode Serial.println("Card Mount Failed"); return; } uint8_t cardType = SD_MMC.cardType(); if(cardType == CARD_NONE){ Serial.println("No SD_MMC card attached"); return; } Serial.print("SD_MMC Card Type: "); if(cardType == CARD_MMC){ Serial.println("MMC"); } else if(cardType == CARD_SD){ Serial.println("SDSC"); } else if(cardType == CARD_SDHC){ Serial.println("SDHC"); } else { Serial.println("UNKNOWN"); } uint64_t cardSize = SD_MMC.cardSize() / (1024 * 1024); Serial.printf("SD_MMC Card Size: %lluMB\n", cardSize); } void loop(){ }
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login