Hi, I bought a 9 DoF sensor stick (this one: http://www.sparkfun.com/products/10183 ), and I’m trying to communicate with the ADXL345 accelerometer over I2C.
My wiring is simply this:
+5V → Vcc
0V → Gnd
Arduino A4 → SDA
Arduino A5 → SCL
And my code (so far) is this:
#include <Wire.h>
const int ACCEL_ADDRESS = 0x1D;
const int ACCEL_POWER_CTL = 0x2D;
const int ACCEL_DATAX0 = 0x32;
const int ACCEL_DATAX1 = 0x33;
void setup()
{
Serial.begin(9600);
Wire.begin();
Wire.beginTransmission(ACCEL_ADDRESS);
Wire.send(ACCEL_POWER_CTL);
Wire.send(0x08);
Wire.endTransmission();
}
void loop()
{
Wire.beginTransmission(ACCEL_ADDRESS);
Wire.send(ACCEL_POWER_CTL);
Wire.endTransmission();
Wire.requestFrom(ACCEL_DATAX0, 1);
while (!Wire.available());
int highx = Wire.receive();
Serial.println(highx);
}
However, it gets stuck at the Wire.available() loop. I found some mention of removing the lines about internal pull-up resistors in twi.cpp which I tried, but it made no difference. Can anyone say what I am doing wrong? Also it would be nice if there was some documentation about how to use this product other than the chip datasheets…
Oh, and I also tried the ADXL345 driver from the FreeIMU library; that didn’t work either.
Please help!