3

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?

himura
  • 440
  • 4
  • 14
  • As above should work OK. How are they connected? A possibility if using a breadboard and jumpers is that you've ended up with too much capacitance on the SPI bus, if they're spaced apart it would be worth trying putting them closer together with shorter jumpers. – PeterJ May 16 '13 at 22:14
  • hmmmmmmm I c. I'll try to solder everything with the least area as possible to minimize that effect (will try that in the lab later). So SPI should work perfectly fine with simple connections. No circuitry needed as pull-up resistors or so? – himura May 16 '13 at 22:20
  • You'll still want a single set of pull-ups on the SPI bus, I'm not familiar with that particular board but check if they are provided on board. If you don't have any at the moment that's another possibility. – PeterJ May 16 '13 at 22:26
  • 2
    I2C needs pullup resistors even for MCU talking to just one device. I2C bus lines are defined by speciication to be driven via open drain type circuits and the pullups are essential to providing the high levels on the signal lines. – Michael Karas May 16 '13 at 23:02

1 Answers1

2

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?

Passerby
  • 72,580
  • 7
  • 90
  • 202
  • Frankly, I think it's a mistake that Sparkfun puts pull-ups on I2C slave modules. What if the design has many modules, and the combined pull-up resistance is too stiff? There was a thread on the subject of [pull-ups on multiple modules](http://electronics.stackexchange.com/q/68096/7036) recently. – Nick Alexeev May 17 '13 at 02:17
  • @NickAlexeev they moved to a solder jumper setup, so you can unsolder the jumper to disable the pullups. Or you can always cut the trace. It's not that hard. NBD. – Passerby May 17 '13 at 02:22
  • No, it's not hard to disable the pull-up. Notice that Arduino doesn't have the (optional) pull-ups, and it's internal pull-ups are too weak for I2C. So, SparkFun schleps pull-ups everywhere else. Easier initial out-of-the-box experience. But add a few slave modules and the bus will stop working. – Nick Alexeev May 17 '13 at 05:19
  • Everything worked now. I didn't change anything, I think it was just some loose connection. I had this fear since some threads were seriously talking about the=is manner such as here: http://forum.arduino.cc/index.php?topic=50010.0 and here: http://forum.arduino.cc/index.php/topic,49987.0.html – himura May 18 '13 at 14:09