The demo code to read and write a test file to the SD card works fine, however, as soon as I connect anything else to the dev board, it fails to init the sd card.
For example - a DS18B20 temperature sensor connected to GPIO 4 and 3.3v and ground, or even just an LED on GPIO13 with a 220K ohm resister to ground seems to make it fail.
This seems to be a power issue, however it happens when connected to USB-5 volt 2.5 amp supply, or the 3.7 volt battery included in the kit.
Any idea on how to fix this?
UPDATE:
I’ve figured it out after taking a deep dive into the libraries, specifically “SD_MMC.h”.
My code assumed the sd card was using pins only 2, 14, 15, the library shows it uses more pins:
* SD Card | ESP32
* D2 12
* D3 13
* CMD 15
* VSS GND
* VDD 3.3V
* CLK 14
* VSS GND
* D0 2
* D1 4
If you use any of these pins, it interferes with the sd card.
I changed my code to use GPIO pins 25, 26 and 27 instead of 4 and 12 and it seems to work ok now.
The program reads an array of five DS18B20 temperature sensors every 10 seconds and writes the results to a data text file on the SD card. A momentary push button starts and stops data recording, an LED indicates the status of the sd card and when it is recording data.
Eventually this will get a touch display, this is just phase one to test the reliability of the ESP32 to perform this function.
Bottom-line: If your SD Card is not behaving as it should make sure you are not using pins 2,4,12,13,14,15