Can't get SD card working on ESP32 WROOM 32E from Camera Pro Kit

I have the Sunfounder ESP32 Camera Pro Kit, which contains the WROOM 32E module. I’m using Arduino IDE, and board “ESP32 Dev Module”, on COM4. I’ve got several simple sketches to work fine, but now I’m trying to use the SD card and I can’t get the board to recognise it. It’s all built-in on this board, with camera module, SD card slot, and battery charging module, so the problem isn’t a wiring one of my making, using wrong pins, etc.

I tried a camera server sample, which failed, so I’ve dropped back to the “2.10 SD Card Write and Read” sample sketch from the tutorial (2.10 SD Card Write and Read — SunFounder ESP32 Starter Kit documentation) and this also fails to recognise the SD card. I’ve mounted the SD card on my PC and it’s FAT32 and I can read/write files from it fine. But the SD_MMC.begin() call just gives me this:

21:06:58.805 -> E (5054) sdmmc_periph: sdmmc_host_clock_update_command(200): sdmmc_host_start_command returned 0x107
21:06:59.805 -> E (6054) sdmmc_periph: sdmmc_host_clock_update_command(200): sdmmc_host_start_command returned 0x107
21:06:59.805 -> E (6054) sdmmc_req: handle_idle_state_events unhandled: 00001000 00000000
21:06:59.805 -> E (6058) sdmmc_req: handle_idle_state_events unhandled: 00001000 00000000
21:07:03.804 -> E (10065) sdmmc_periph: sdmmc_host_clock_update_command(200): sdmmc_host_start_command returned 0x107
21:07:03.804 -> E (10065) sdmmc_common: sdmmc_init_ocr: send_op_cond (1) returned 0x107
21:07:03.804 -> E (10069) vfs_fat_sdmmc: sdmmc_card_init failed (0x107).
21:07:03.804 -> Failed to mount SD card

Any help would be greatly appreciated.

We recommend that you provide us with a video of the operation process so we can better analyze and resolve the issue.

If the video file is large, please upload it to OneDrive and share the link with us, granting us access.

Hi, thanks for responding.

I’m not sure these videos add much to what I already wrote above, but here is a video of the compile/upload process failing, showing the full script (from the Sunfounder online samples for this Camera Pro Kit) and the serial port output.

[Later] Ah, your forum is saying, “Sorry, new users can not upload attachments.” So here is a link to two videos: the compile/upload/error video, and one showing the board and SD card insertion:

https://1drv.ms/f/s!AmNj7TsOYKRMsNxlCtHrou79y61z7g?e=9s3s0s

The SD card is a good quality Kingston one – 32GB CANVAS Select Plus. It works fine when inserted in my laptop. Since posting originally here I’ve taken the card out of the ESP32 module and reformatted it (FAT32 as before), put a test file on it in Windows, and then re-inserted it into the slot on the board, but still no joy.

Do you have any other SD cards? Try switching the SD card and see if it works.
Have you connected the battery to power the expansion board? Try connecting the battery to the expansion board and check the working conditions.

OK, I bought a new 32GB micro SD card, and get the exact same output from the test script in my video:

19:03:06.913 -> SD_MMC.begin()
19:03:12.969 -> E (8053) sdmmc_periph: sdmmc_host_clock_update_command(200): sdmmc_host_start_command returned 0x107
19:03:13.955 -> E (9053) sdmmc_periph: sdmmc_host_clock_update_command(200): sdmmc_host_start_command returned 0x107
19:03:13.955 -> E (9053) sdmmc_req: handle_idle_state_events unhandled: 00001000 00000000
19:03:13.955 -> E (9057) sdmmc_req: handle_idle_state_events unhandled: 00001000 00000000
19:03:17.989 -> E (13064) sdmmc_periph: sdmmc_host_clock_update_command(200): sdmmc_host_start_command returned 0x107
19:03:17.990 -> E (13064) sdmmc_common: sdmmc_init_ocr: send_op_cond (1) returned 0x107
19:03:17.990 -> E (13068) vfs_fat_sdmmc: sdmmc_card_init failed (0x107).
19:03:17.990 -> Failed to mount SD card

Here’s the code snippet:

#include "SD_MMC.h"

void setup() {    // This is one of the sample scripts from the online tutorial for the "ESP32 Camera Pro Kit" with ESP32 WROOM 32E Module
  delay(1000);    // I added some extra delays to ensure serial comms/debug messages displayed correctly
  Serial.begin(115200); // Initialize serial communication
  delay(1000);
  // Serial.println("Setting pins");
  // SD_MMC.setPins(14, 15, 2, 4, 12, 13); // I tried it with and without this addition, but it made no difference
  // delay(1000);
  Serial.println("SD_MMC.begin()");
  delay(1000);
  if (!SD_MMC.begin()) { // Check if SD card is mounted successfully
    Serial.println("Failed to mount SD card"); // Print error message if SD card failed to mount
    return;
  }
}

I’ll try with the battery connected, but it would be good if it worked without the battery if needed.

Nope, same thing happens with charged battery connected:

19:19:44.297 -> ets Jul 29 2019 12:21:46
19:19:44.297 ->
19:19:44.297 -> rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
19:19:44.297 -> configsip: 0, SPIWP:0xee
19:19:44.297 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
19:19:44.297 -> mode:DIO, clock div:1
19:19:44.340 -> load:0x3fff0030,len:4832
19:19:44.340 -> load:0x40078000,len:16460
19:19:44.340 -> load:0x40080400,len:4
19:19:44.340 -> load:0x40080404,len:3504
19:19:44.340 -> entry 0x400805cc
19:19:46.512 -> SD_MMC.begin()
19:19:52.495 -> E (8053) sdmmc_periph: sdmmc_host_clock_update_command(200): sdmmc_host_start_command returned 0x107
19:19:53.493 -> E (9053) sdmmc_periph: sdmmc_host_clock_update_command(200): sdmmc_host_start_command returned 0x107
19:19:53.539 -> E (9053) sdmmc_req: handle_idle_state_events unhandled: 00001000 00000000
19:19:53.539 -> E (9057) sdmmc_req: handle_idle_state_events unhandled: 00001000 00000000
19:19:57.504 -> E (13064) sdmmc_periph: sdmmc_host_clock_update_command(200): sdmmc_host_start_command returned 0x107
19:19:57.549 -> E (13064) sdmmc_common: sdmmc_init_ocr: send_op_cond (1) returned 0x107
19:19:57.549 -> E (13068) vfs_fat_sdmmc: sdmmc_card_init failed (0x107).
19:19:57.549 -> Failed to mount SD card

So this is two cards, in both battery-powered and non battery-powered configuration.

Is this supposed to “just work”? Do you know what error code 0x107 is? Do I need to tie any pins high or low (it doesn’t say so in the tutorial)? Could there be a fault with this board? Has anyone else managed to get the SD card working on this ESP32 Camera Pro Kit with WROOM 32E?

1.If it is inserted correctly, there may be an issue with the SD card. You can try cleaning the metal contacts with an eraser.
2.If the problem persists, it is recommended to format the SD card.How to format the SD card? — SunFounder ESP32 Starter Kit documentation
3.It is suggested to try using other USB ports on your computer to see if it works.
image (33)