3
\$\begingroup\$

I have an ADXL345 accelerometer on a Makershield stacked on top of a Seeed SD card shield. Both of those are stacked on an Arduino UNO R2.

I've got each working individually, but when stacked they share pin 12. The SD Card shield uses 12 for MISO of SPI and the ADXL345 uses it for SDO/Alt address.

I'm new to Arduino and have not stacked shields like this before. I'm not sure what the best course of action is here to get them both working, Ultimately, I want to log the data from the accelerometer to the SD card, but first things first!

I'd be grateful for any help. I've linked the data sheets for the ADXL345 and the SD shield above.

\$\endgroup\$
  • \$\begingroup\$ What type of equipment (soldering iron and its quality, multimeter, anything else?) do you have and how much are you prepared to modify the shields? \$\endgroup\$ – AndrejaKo Mar 17 '13 at 18:46
  • \$\begingroup\$ I've got everything I need to modify the shield, and am assuming that's what has to happen -- glad for any guidance. And thanks for the quick response! \$\endgroup\$ – Jeff Severns Guntzel Mar 17 '13 at 18:49
  • \$\begingroup\$ @JeffSevernsGuntzel FYI. Check out the proposed dedicated Arduino board on SE. I bet, they would benefit from your participation. \$\endgroup\$ – Nick Alexeev Mar 17 '13 at 19:11
  • \$\begingroup\$ Off topic, but something funny about the ADXL345 - given that it uses /CS being tied high to select I2C mode, it's not clear when connected on a shared SPI bus what (other than improbability) would keep it from potentially misinterpreting SPI access to some other slave-selected device as an I2C access to itself, and trying to respond. \$\endgroup\$ – Chris Stratton Mar 17 '13 at 19:17
  • \$\begingroup\$ @ChrisStratton The potential problem with I2C and SPI pin sharing was detailed in this thread. \$\endgroup\$ – Nick Alexeev Mar 18 '13 at 6:29
2
\$\begingroup\$

Your best solution will depend on which mode you are operating the ADXL345 in.

If you are operating it in SPI mode, then pin 12 is being used for the same role on both boards, and they should be able to share simply by taking turns - only the one which has (had) its slave select activated should be driving return data.

If you are operating it in I2C mode, then you can cut the trace or remove the pin from the shield and permanently wire it high or low depending on which address you want to select. It's also possible that you could reconfigure pin 12 as an ouput and drive it high or low whenever you want to talk to the ADXL345, then make it an input again when talking to the SD. Even putting a pullup resistor on it would be likely to work - that would let the ADXL345 see it as a high (just a reliable value to control the address) and still let the SD card override it to send data.

If you don't know which mode is being used, look through the code (for the library) you are using to interact with it. (As a guess, it's probably I2C mode, because if it were SPI it would probably want to use most of the same pins the SD shield were using, instead of just one). Or check the /CS pin - if it's wired high you have I2C mode, if it's connected to an Arduino pin you might have SPI.

\$\endgroup\$
  • \$\begingroup\$ Thank you, Chris. I'm going to dig in following your guidance here... \$\endgroup\$ – Jeff Severns Guntzel Mar 17 '13 at 19: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.