2

I'm using the ADXL345 accelerometer with i2c. I've connected one to my PI and get good data. I use 3.3V, SDA, SDL and Ground. My project needs two ADXL345 units. So I hooked up a second. Both come off the same 4 pins on the PI (Pins 1,3,5,9).

Of course, this "works" but the data are mixed up, I cab't read each ADXL345 independently. The default address is 0x53 when SDO is low (https://wiki.analog.com/resources/tools-software/linux-drivers/input-misc/adxl345). As you can see, I have hooked up nothing to SDO on either unit, so both units are low and report address 0x53. I can verify this with "sudo i2cdetect -y 0".

Per the wiki entry referenced above, if SDO is high on one unit, it should report address 0x1D. Then I will have two units that are uniquely addressable.

I thought that all I would need to do is apply 3.3V to the SDO pin to keep it high. For my second unit I added one wire from 3.3v to the SDO pin. After making this connection, the PI would not boot. No lights, nothing. Pulling this one wire off, and the PI booted (although with both devices back to address 0x53 as expected).

Can anyone point out what I am doing wrong? Since applying 3.3v to the SDO pin doesn't seem to be the way to set SDO high, how should I do it? Your advice appreciated. I'm new to this.

  • Could you post an image and the specs of the actual modules you are using? The chances of you using bare ADXL345 devices is pretty remote. – joan Oct 5 '15 at 8:20
  • It is this one: amazon.com/gp/product/B008B4W1QS – Special Agent Jel Oct 5 '15 at 21:45
  • Just note that the one you linked to on Amazon is I2C configged by default, and to make it work as SPI a commenter mentioned The board is initially wired for I2C operation. But can easily be converted to work with SPI - by removing a few resistors. Also includes a 3.3V regulator on-board. Take that into account when looking at my answer below. – Phil B. Oct 6 '15 at 0:02
2

I'd recommend trying one of two things:

  1. Configure one to be used as I2C and the second as SPI. According to the wiki you reference, the device can be used in either mode.
  2. Instead of using the 3.3V pin to make SDO high, use a GPIO pin in output mode, and put a resistor (1k-10kOhm) on the connection between the GPIO pin and the SDO pin on the ADXL345.

What is likely happening is that by connecting directly to 3.3V, your device is trying to pull max current from the rPi, which in turn triggers a protection mechanism (as the 3.3V pin is limited to 50mA). Putting in the resistor should limit this (3.3V over 1kOhm = 3mA). You could try to do option 2 as well by connecting to 3.3V with the same resistor, but by using a GPIO pin you have more control. Actually, you should give both ADXL345's a GPIO pin, and explicitly set one to 0 and another to 1. Otherwise the ADXL's input might float sometimes (unless there is a pulldown resistor built in) and you still get a conflict.

  • The GPIO sounds like a good approach. As soon as I can get back to the project I'll give that a whirl. – Special Agent Jel Oct 5 '15 at 21:47

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.