Issue with Arduino Due, multiple Devices on SPI bus

Hello fam,

I try to read accelerometer data onto an sd-card. Both devices communicate through SPI.

I use an ADXL-355 pmdz as the accelerometer, a 3.3V device.

Then, I use a simple sd-card module: https://www.amazon.co.uk/Storage-Memory-Shield-Module-
Arduino/dp/B01INGOJJU, a 3.3V device with an onboard 3.3V regulator.

Additionally, I use an Arduino Due, a 3.3V device.

My issue is that if the accelerometer is connected by itself, it gives me the desired data, printed on the serial port. As soon as I connect the VCC pin of the sd card module to 5V, the accelerometer stops working and writes -0.00 to the serial port.

Now I don’t know why this is the case, could it be that the bus all of the sudden becomes 5V lines when a 5V device connects with the bus (even though it is actually a 3.3V device with an onboard regulator, that I have to connect to 5V otherwise it does not work)?

I attached a picture of the wiring.

here is some of the code I use for communication

    while (!Serial) {
    }
        Serial.print("Initializing SD card...");

        if (!SD.begin(CS_PIN)) {
            Serial.println("Card failed, or not present");
            // don't do anything more:
            while (1);
        }
 
        myFileAcc = SD.open("7.txt", FILE_WRITE);
        Serial.println("card initialized.");


unsigned int readRegistry(uint8_t thisRegister) {
  unsigned int result = 0;
  uint8_t dataToSend = (thisRegister << 1) | READ_BYTE;

  digitalWrite(CHIP_SELECT_PIN, LOW);
  SPI.transfer(dataToSend);
  result = SPI.transfer(0x00);
  digitalWrite(CHIP_SELECT_PIN, HIGH);
  return result;
}


void writeRegistry(byte thisRegister, byte thisValue) {
  byte dataToSend = (thisRegister << 1) | WRITE_BYTE;
  digitalWrite(CHIP_SELECT_PIN, LOW);
  SPI.transfer(dataToSend);
  SPI.transfer(thisValue);
  digitalWrite(CHIP_SELECT_PIN, HIGH);
}

Thank you!

Then, I use a simple sd-card module: https://www.amazon.co.uk/Storage-Memory-Shield-Module-
Arduino/dp/B01INGOJJU, a 3.3V device with an onboard 3.3V regulator.

Most of these cheap SD card reader modules have an error in their level converter (although not necessary for an 3V3 MCU, they still have one), that make them non-compliant with an SPI bus. The boards still work if they are the only device on the bus but every other device connected to the bus will fail.

There are tutorials on the Internet about how to fix these boards (it's just one connection that is wrong) but you need quite sophisticated soldering skills as you have to change SMD tracks.

If you don't have good soldering skills, buy an SD card board from a serious supplier (e.g. Sparkfun, Adafruit, etc.) as they know how to do their job.

+1

Thank you. I will try a different module then :slight_smile: