Two SPI devices not working together

I have struggled with the same problem, namely connecting a SD-card reader and a NRF24L01 to an ESP32 through SPI, simultaneously. I have done a thorough web research. Here are my insights and my amazingly simple solution to the problem:

root course:

The SD card reader is using a 3.3V to 5 V level shifter. However, there is a flaw in the circuit, unfortunately: the level shifter does NOT enter tri-state, when the circuit is disabled through the CS (chip select) line. This leads to the situation, that the NRF24L01 cannot send data over the MISO line, as this line is either HIGH or LOW, depending of what the SD-card reader is sending.

The reference for this insight is this: SOLVED. Nrf24 (Mirf lib) + Micro SD-card works OK together

solution

The hardware bug of the SD-card reader board can be fixed directly. Please refer to the above link. But I found this fix very delicate and decided to look for an alternative approach.

I came across two approaches:

  1. the proper way of fixing this would be to put a tri-state driver in the MISO line leaving the SD-card-reader. The chip would be 74HC125. The enable pin of the driver would be connected with the chip select line of the SD-card reader (connect both the enable pin of the SD-card reader and the enable pin of the driver with the chip select line from your Arduino). I have not tried this out, but I am very sure it would work.

  2. as I did not have a 74HC125 on hand, I used this simple approach instead:

  • connect the MISO-output of the NRF24L01 directly with the MISO input of the Arduino.
  • connect the MISO-output of the SD-card reader through a 4.7k resistor with the Arduino.

The effect is the following:

  • if the nrF24L01 is enabled, the nrf24L01 MISO signal is leading, regardless of the output of the SD-card MISO. The worst that can happen is a few hundred µA current through the resistor. However, the potential at the Arduino input is not distorted very much.

  • if the nrf24L01 is disabled, it's MISO-output if tri-state, which means, it has a high resistance. Therefore, the MISO-signal of the SD-card reader reaches the Arduino through the resistor, without much loss of voltage.

I hope this fix helps.

Best regards

Ludwig

2 Likes