I spent a surprising amount of time today trying to get the ESP32 to read and write to the SDCARD via SPI. I checked kept getting a variety of errors from their own example program sd_card_example_main.c (esp-idf/examples/storage/sd_card/):-
- E (1386) sdmmc_common: sdmmc_init_ocr: send_op_cond (1) returned 0x107
- E (1406) example: Failed to initialize the card (ESP_ERR_TIMEOUT). Make sure SD card lines have pull-up resistors in place.
- E (358) sdmmc_sd: sdmmc_init_sd_if_cond: send_if_cond (1) returned 0x108
- E (378) example: Failed to initialize the card (ESP_ERR_INVALID_RESPONSE). Make sure SD card lines have pull-up resistors in place.
As per the helpful error messages I checked that the pull-up resistors were in place and then double checked that all the SPI connections were correct. Still I got one of the above error messages (depending if I removed some of the pull-ups or not).
I thought it might be something to do with the SDCARD so I tried another one still without any luck.
Like most people I then consulted Dr. Google and found a number of other people who had the same problem, there were a few suggestions which I had already tried, and a couple of extras which didn’t make any difference.
I didn’t find any messages where the original poster replied saying that they had solved the problem so either they gave up, didn’t post a follow up or found a way of fixing it but not bothering to post the solutions to their own problem.
Anyway I eventually found the solution that fixed “my problem” and I’m not going to hide the solution no matter how obvious it might seem now!
The problem arose because the ESP32 is a 3v3 device, hence I connected the 3v3 pin to the VCC connector on the TFT / Touch Screen / SDCARD module. I had already had the TFT and Touch Screen working with that configuration so didn’t give it a second though. Anyway, the solution that fixed my problem was to connect the VCC connector to the ESP32 VIN pin which was 5V doh!