ESP32 Two SPI devices RF24 and SD card

Hi,

I’m trying to get two SPI devices to work with my ESP32 but for some reason it doesn’t work

When using the code beneath with all the SD code commented out my RF24Mesh works and detects Slaves in the network, but when i use the code just like the following code the RF24Mesh does not work any more.
The SD card isn’t working either (but that’s probably a problem for future me I suppose).

I tried different pins, speeds and example codes but nothing seem to work.

#include "RF24Network.h"
#include "RF24.h"
#include "RF24Mesh.h"
#include <SPI.h>
#include <EEPROM.h>
//#include "FS.h"
#include <SD.h>
//#include <time.h> 
//#include <WiFi.h>

/***** Configure the chosen CE,CS pins *****/
RF24 radio(17,5);
RF24Network network(radio);
RF24Mesh mesh(radio,network);

/***** SD Card SPI *****/
SPIClass spiSD(HSPI);
#define SD_CS 13
#define SDSPEED 16000000

uint32_t displayTimer = 0;

void setup() {
 Serial.begin(115200);
 
 // Set SD Card SPI
 spiSD.begin(14,2,15,13);//SCK,MISO,MOSI,CS
 if(!SD.begin( SD_CS, spiSD, SDSPEED)){
   Serial.println("Card Mount Failed");
   return;
 }

 // Set the nodeID to 0 for the master node
 mesh.setNodeID(0);
 Serial.println(mesh.getNodeID());
 // Connect to the mesh
 mesh.begin();

}

void loop() {    

 // Call mesh.update to keep the network updated
 mesh.update();
 
 // In addition, keep the 'DHCP service' running on the master node so addresses will
 // be assigned to the sensor nodes
 mesh.DHCP();
 
  // Check for incoming data from the sensors
 if(network.available()){
   RF24NetworkHeader header;
   network.peek(header);
   
   uint32_t dat=0;
   switch(header.type){
     // Display the incoming millis() values from the sensor nodes
     case 'M': network.read(header,&dat,sizeof(dat)); Serial.println(dat); break;
     default: network.read(header,0,0); Serial.println(header.type);break;
   }
 }
 
 if(millis() - displayTimer > 5000){
   displayTimer = millis();
   Serial.println(" ");
   Serial.println(F("********Assigned Addresses********"));
    for(int i=0; i<mesh.addrListTop; i++){
      Serial.print("NodeID: ");
      Serial.print(mesh.addrList[i].nodeID);
      Serial.print(" RF24Network Address: 0");
      Serial.println(mesh.addrList[i].address,OCT);
    }
   Serial.println(F("**********************************"));
 }
}

Hope someone can point me in the right direction.

Thanks in advance

And once again we have to ask for the same stuff: Without links to the exact hardware you're using we have to guess. My guess is you have one of these Chinese SD card readers that doesn't tri-state the MISO line if CS is pulled high.

For some models there are hardware fixes on the Net for skilled solderers. In most situations is easier (and cheaper) to buy an SD card reader from a supplier that does it right (and provides schematics for it's products).

All SPI devices on the HSPI buss of a ESP32 must not generate any signal action during the upload/boot/reboot process. For those devices that start talking during the upload/boot/reboot process I put them on the VSPI buss.

One could, also do a HSPI pin remap.

If one has the interest using the ESP32 SPI API is a much better option.