ADXL345 + arduino ???

Can anyone tell me how to connect ADXL345 with arduino???

Thanks!

What type of Arduino do you have?

It’s actually pretty easy to connect and/or to communicate as the device supports both SPI and TWI (I2C).

Thanks for your reply!

I am using Duemilanove.

I tried to connect them. However, it doesn’t work! Can you tell me what went wrong?

http://www.2hubs.com/jobs/projects/ADXL345_Arduino.jpg

First you need to decide whether you want to use SPI or TWI. I’d suggest TWI for the beginning, but it really doesn’t matter that much.

After a first glance at the ADXL’s datasheet I think you only need to connect GND, VCC, SCL and SDA in case you want to use, for example, TWI. You can then use the Arduino’s accompanying Wire library to communicate with the chip. All neccessary information can be found in the ADXL’s datasheet.

As for the connections labeled “A0”, “A1” and “A2”, I cannot tell you whether these are the right ones or not. Your Arduino probably has an ATmega168 on board and hence SDA and SCL have to be connected to the ATmega’s PC4 and PC5 pins, respectively. Have a look at the Arduino datasheet in order to determine which of the Arduino’s pins are connected to the controller’s PC4 and PC5. (I think the culprits are the Arduino’s “analog input 5” (SCL) as well as “analog input 4” (SDA), see [here)

HTH!](http://arduino.cc/en/Hacking/PinMapping168)

According to the data sheet, you can run the ADXL345 at 3.3v - that should simplify things. In any case. you DON’T want a diode in the ground path as that will shift your logic references around.

You should have a 1uf - 10uf tantalum along with the 100nf ceramic for decoupling the power supply, and may even want a bead or 100R resistor in series with Vs to reduce noise…

From my experience, when using I2C, you wire SDA & SCL directly to the arduino’s analog pins 4 & 5.

Because I2C is a two way communication, i wouldn’t put a diode on the lines.

The only other thing to remeber is that I2C requires “pull up” resistors.

This means the data lines need a resistor between them and the logic voltage (5 volts) to “pull them up” to 5 volts.

When i’ve done this i’ve used 1K to 10K ohm resistors to 5 volts. However, the chip uses 3.3 volts so try that first, other wise u may break it.

Here is a tutorial on how to wire up a eeprom chip using I2C, there are visual examples there. http://www.ghettohax.com/2009/02/i2c-ee … duino.html Remember though, tie them to 3.3 volts first

I’m about to buy one of these, so hopfully this fix is the answer.

Good luck!