3
\$\begingroup\$

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?

\$\endgroup\$
  • \$\begingroup\$ 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. \$\endgroup\$ – PeterJ May 16 '13 at 22:14
  • \$\begingroup\$ 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? \$\endgroup\$ – himura May 16 '13 at 22:20
  • \$\begingroup\$ 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. \$\endgroup\$ – PeterJ May 16 '13 at 22:26
  • 2
    \$\begingroup\$ 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. \$\endgroup\$ – Michael Karas May 16 '13 at 23:02
2
\$\begingroup\$

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?

\$\endgroup\$
  • \$\begingroup\$ 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 recently. \$\endgroup\$ – Nick Alexeev May 17 '13 at 2:17
  • \$\begingroup\$ @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. \$\endgroup\$ – Passerby May 17 '13 at 2:22
  • \$\begingroup\$ 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. \$\endgroup\$ – Nick Alexeev May 17 '13 at 5:19
  • \$\begingroup\$ 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: forum.arduino.cc/index.php?topic=50010.0 and here: forum.arduino.cc/index.php/topic,49987.0.html \$\endgroup\$ – himura May 18 '13 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.