B4R Question Initialize rSD with other pins (MISO,MOSI,SCK,CS)


Licensed User
Longtime User
I'm trying to use an SD CARD module with the TTGO TCALL SIM800L.(Based on ESP32)
the TTGO TCALL SIM800L V1.4 uses pin23 as PWR and this same pin is MOSI for SDCARD
In version 1.3 it would conflict with pin 5. RST to SIM800L and VPPI_SS (CP)

I can't use the SPI pins because I need to use also the SIM800L module.

The rSD library uses by default the MOSI(23),MISO(19),SLK(18) and CS(5) pins.(These pins are assigned for SD CARD in TTGO TCALL SIM800L)
The rSD library only allows to initialize the CS pin (sd.Initialize(MY_CS) )
I need to configure other pins for SDCARD:

In Arduino IDE it works I have it configured like this and it works fine
#define MY_CS       14
#define MY_SCLK     18
#define MY_MISO     19
#define MY_MOSI     15
void setupSDCard()
    //Assuming use of SPI SD card
    if (!SD.begin(MY_CS, SPI1)) {
        Serial.println("Card Mount Failed");
    } else {
        Serial.println("SDCard Mount PASS");
        String size = String((uint32_t)(SD.cardSize() / 1024 / 1024)) + "MB";

How can I initialize rSD like this:

SD.initialize(MY_SCLK, MY_MISO, MY_MOSI, MY_CS);

Thanks for your help!!!!
Last edited:


Active Member
Licensed User
do you want to check if this version of SD adapted for esp32 can help you ?

this library take in account the 3 versions of esp32 known in SPI library for esp32.
' ESP32:
' FSPI = 1, SPI attached To flash / normally Not used
' HSPI = 2, uses SPI2 => MOSI (13), SCK (14), MISO (12), SS (15)
' VSPI = 3, uses SPI3 => MOSI (23), SCK (18), MISO (19), SS (5)
' VSPI is SPI by default

' ESP32-S2:
' FSPI = 1, uses SPI2 =>MOSI (13), SCK (14), MISO (15) And SS (12) / 6 SS lines any other pin
' HSPI = 2, uses SPI3 =>MOSI (35), SCK (36), MISO (37) And SS (34) / 3 SS lines at any other pin
' VSPI Not defined

' ESP32 C3:
' FSPI = 0, uses SPIx =>MOSI (5), SCK (6), MISO (7) And SS (10) / 6 SS lines any other pin
' HSPI Not defined
' VSPI Not defined

with this library, you can choose between 4 initialize depending of your configuration:
bool Initialize(uint8_t spi, uint8_t SDss, bool format_if_empty);
bool Initialize1(uint8_t spi, uint8_t SDss, ULong frequency, byte max_files, bool format_if_empty);
bool Initialize2(uint8_t spi, uint8_t SDss, uint8_t SCLK, uint8_t MISO, uint8_t MOSI, bool format_if_empty);
bool Initialize3(uint8_t spi, uint8_t SDss, uint8_t SCLK, uint8_t MISO, uint8_t MOSI, ULong frequency, byte max_files, bool format_if_empty);

several SPI types are defined to select VSPI/HSPI/VSPI depending of esp version
#define /*byte ESP32_FSPI;*/ B4R_FSPI 0x1
#define /*byte ESP32_HSPI;*/ B4R_HSPI 0x2
#define /*byte ESP32_VSPI;*/ B4R_VSPI 0x3
#define /*byte ESP32C3_FSPI;*/ B4RC3_FSPI 0x0
#define /*byte ESP32C3_HSPI;*/ B4RC3_HSPI 0x1
#define /*byte ESP32S2_FSPI;*/ B4RS2_FSPI 0x1
#define /*byte ESP32S2_HSPI;*/ B4RS2_HSPI 0x2

and after selection of SPI type, you can select what pins you want to use .

i hope it can answer at all configurations.


  • rSD32.zip
    4 KB · Views: 147
Upvote 0