I have a custom shield i have made that holds an analog accellerometer, a HMC5883L compass, an analog gyro, and an ADXL345 digital accellerometer. Whenever i try to read the ADXL345 data over i2c, i get all zeros . I've been trying different examples, and none of them work. Here are some of the tutorials and example code i've used:
http://bildr.org/2011/03/adxl345-arduino/
http://www.sparkfun.com/tutorials/240
/************************************************************************
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU License V2. *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License, version 2 for more details *
* *
* Bare bones ADXL345 i2c example for Arduino 1.0 *
* by Jens C Brynildsen <http://www.flashgamer.com> *
* This version is not reliant of any external lib *
* (Adapted for Arduino 1.0 from http://code.google.com/p/adxl345driver)*
* *
* Demonstrates use of ADXL345 (using the Sparkfun ADXL345 breakout) *
* with i2c communication. Datasheet: *
* http://www.sparkfun.com/datasheets/Sensors/Accelerometer/ADXL345.pdf *
* If you need more advanced features such as freefall and tap *
* detection, check out: *
* https://github.com/jenschr/Arduino-libraries *
***********************************************************************/
This file has been truncated. show original
I've ruled out the possibility of i2c errors by using the accellerometer without the compass (also an i2c device). Any ideas?
Do you get any response from the device when you run the I2CScanner sketch ?
Have you considered 5/3 volt issues if they are relevant to your system ?
I'm getting addresses at 0x1D and 0x1E. ox1E is an HMC5883L compass (i pulled it out, and got only 0x1D). I'm 99% sure that the system uses 5v, because it takes 5v power.
Got it working!!
The library i was using was set to address 0x53 for some reason, I changed it and now it works fine!