Page 1 of 1

ESP32-Arduino: How to use SD library with VSPI

Posted: Tue Dec 04, 2018 1:25 pm
by birdofpreyX
Hello,

what changes exactly do I need to perform in sd.h and sd.cpp of the SD library to change the SD-Drive connection references from standard HSPI to VSPI. Im using a ESP32 Devkit board:
https://github.com/espressif/arduino-es ... braries/SD

I have a kind of Mode 1 SPI Sensor on HSPI which does not accept other devices on the same bus.

I want to use both SPI (sensor and sdcard reader) with this method:
https://github.com/espressif/arduino-es ... _Buses.ino

Sorry for this probably easy question, but Im a newbie.

Thank you very much for your help.

Re: ESP32-Arduino: How to use SD library with VSPI

Posted: Wed Dec 05, 2018 1:13 pm
by FreddyVictor
OK, proviso, I'm new to ESP32....

I don't believe you need to make any changes to the sd.* files
Just use the code as per your link
Connect sdCard to vspi pins:
//SCLK = 18, MISO = 19, MOSI = 23, SS = 5
and connect your sensor to hspi pins:
//SCLK = 14, MISO = 12, MOSI = 13, SS = 15

or, you can choose whatever pins you want by using the:
spi->begin(sck_pin_no, miso_pin_no, mosi_pin_no, ss_pin_no);
function instead

SPI is a straightforward protocol (unlike i2c) and can easily be 'bit-banged' (if no hardware support)