Electronic – arduino – should I use 2 SPI devices on Arduino UNO/PRO or 2 I2C devices

arduinoi2cspi

I am using a microSD breakout board and the accelerometer ADXL345 https://www.sparkfun.com/products/9836.

each one alone works perfectly fine, but once I put both (sharing pins 11,12,13, but with different CS pins) nothing works.

I'm using another sensor with the I2C which is the BMP085: https://www.sparkfun.com/products/11282

The accelerometer also works in I2C, but that requires pull-up resistors when several devices share I2C.

I wanted SPI as it seemed simpler where i can just specify the CS and everything should've worked.

Am I missing something in the SPI case? Is it better to share devices on I2C rather than SPI?

Best Answer

The choice really makes little difference when you are using the Arduino libraries. You should see the same type of performance.

As for the i2c pullup resistors, the BMP085 board you link to has pullups already on the board, connected to a closed solder jumper. Those same pullups should be enough for both sensors, so you wouldn't need to add more.

But there is no reason the sensor shouldn't work on SPI with a sd card as well. Did you double check that you tied all grounds together? How does it not work? Does it only work for one read/write before failing? Are you making sure you drive both CS pins to a high/low, instead of leaving one as a floating input?