I am running into an issue where each device works perfectly fine by itself over SPI, but as soon as I put these two on the same SPI interface, only the DPS initializes and the SD card fails to do so. I believe that the SD card reader works with other SPI devices as I tried to use it alongside an SPI display and it worked just fine.
Maybe I am missing something very obvious, regardless, I provided my code below.
there can be problems with common SD card readers when sharing a SPI bus with other devices, see Sharing the SPI bus among SD card and other SPI devices
one approach is to use a microcontroller with two SPI interfaces
what microcontroller are you using?
What board are you using? I hope it's not a 5V board as that SD breakout board doesn't have level shifters.
Never mind, I just saw your answer.
Since it's just a breakout of the bare card, there shouldn't be any MISO issues with that. Which leaves your pressure sensor.
One test worth making would be to hook up the pressure sensor, and wire 2 4.7K resistors from its MISO line - one to ground and one to 3.3V. Write a little sketch that sets up SPI but leaves the CS pin unselected (high). Then measure the voltage on the MISO line. If it's around 1.65V, great; the pressure sensor is properly tristating MISO when it's not selected. If it's 3.3V or 0V - there's your problem.
I use this. The SPI interfaces must be disabled or they will crosstalk (bus contention) during the begin calls. The SD.begin() function will probably fail without this. This is the only time you need to set the CS pins on them. The libraries should handle the CS lines once the begin calls are complete.
void setup() {
Serial.begin(9600);
while (!Serial) delay(10);
# disable SD SPI
pinMode(SD_CS,OUTPUT);
digitalWrite(SD_CS,HIGH);
# disable DPS310 SPI
pinMode(DPS310_CS,OUTPUT);
digitalWrite(DPS310_CS,HIGH);
# rest of your code.
Sorry for a while of no response. I have tried this and I got 1.71V on the MISO bus. I additionally decided to test this with a BMP390 and got the same result where only one initializes and the other one fails. Could this be a problem with the SD reader?
1.71V is a good sign. That's only a few percent above 1.65V and is easily explained by resistor tolerances and Vcc maybe not being exactly 3.3V. It sounds like the pressure sensor is properly tristating MISO.
You say you got the same result with a different pressure sensor, hmm? Interesting. I wouldn't have thought that the SD reader would be the problem; it's a bare breakout and the SD card ought to properly tristate MISO. Though I suppose you could repeat the "check for tristate" experiment with it to verify that.
I don't have a BMP390 here but I do have a BME280 so when I have some time I'll through it, a bare SD breakout board and an SPI OLED on a handy Wemos D1 and just see what happens. I expect it to Just Work but the truth's in the trying.
Thank you Van! I suspect the SD breakout but I thought the same exact thing is that there is nearly nothing in between... Let me know how it goes! I might get a different SD breakout to try.
As I suspected, it Just Worked (once I moved the BME280's CS pin off one of the ESP8266's "pins which must not be pulled high at startup"). uSD, BME280 and an SPI SSD1306. And as @SurferTim noted, I made sure all the CS pins were set HIGH before anything else was done.
I've never used a Nano 33 BLE but I can't imagine there's something in it that objects to more than one peripheral on SPI. Edit: and as you noted in your original message, the SD breakout worked just fine with other SPI devices.
The only thing I can see, and I'm grasping at straws here, is that the Adafruit uSD breakout has 47K pullups on all the SPI lines. Why that should make any difference, I have no idea. The breakout I have is just direct connections to the card and nothing else. But I can't imagine it would make any difference at all.
I suspect the problem may involve Adafruit's level translation circuit. It's the same in both the DPS310 and the BME280. On two of the lines, when the line goes low, it has, in effect, two 10K pullup resistors in parallel to 3.3V. SPI is supposed to be a push/pull thing, with no pullup resistors. Still, you'd think it would work. So I don't know what's going wrong. Both sensors also appear to have the same goofy "SPI or I2C" option, which may be causing something strange to happen.
But my point is that the DPS310 and BME280 are NOT two different SPI devices, and I suspect either of them could cause the same problem even if the SD breakout is working right. You need to test the SD module with something completely different.
Do you have the option of using I2C for the sensor?
I do not have the option for I2C. However, I tested the BMP390 and SD reader with a separate setup (like @van_der_decken did) and with a different version of the 33 ble and it works just fine.
The top connector is for the display, the middle for the sensors, and the bottom of course for the SD card. Can something like this have an effect? I additionally double and triple-checked my PCB and the wiring doesn't seem to be the problem.