Hi Everyone.
Im trying to connect a Grove - ADXL345 - 3-Axis Digital Accelerometer(±16g) to my Ardunio Uno R3 but I keep getting the following output when using serial monitoring. I swapped out the Grove - ADXL345 - 3-Axis Digital Accelerometer(±16g) for another and I get the same results with that one too.
Failed to initialize ADXL345 accelerometer.
Below is my code.
#include <Wire.h>
#include <ADXL345_WE.h>
ADXL345_WE accelerometer = ADXL345_WE(0x53);
void setup() {
Serial.begin(9600);
while (!Serial);
if (!accelerometer.init()) {
Serial.println("Failed to initialize ADXL345 accelerometer.");
while (1);
}
accelerometer.setRange(ADXL345_RANGE_16G);
}
void loop() {
xyzFloat rawValues = accelerometer.getRawValues();
Serial.print("x: "); Serial.print(rawValues.x);
Serial.print(" y: "); Serial.print(rawValues.y);
Serial.print(" z: "); Serial.println(rawValues.z);
delay(100);
}
I dont think this should be overly difficult but I cant seem to solve this. I confirmed SDA is connected to SDA on the Arduino board (Also tried connecting it to A4 - no luck), I confirmed SCL is connected to SCL (Also tried connecting it to A5 - no luck).
I ran the following IC2 scanner to confirm the sensor is at 0x53
#include <Wire.h>
void setup() {
Wire.begin();
Serial.begin(9600);
Serial.println("\nI2C Scanner");
}
void loop() {
byte error, address;
int nDevices;
Serial.println("Scanning...");
nDevices = 0;
for (address = 1; address < 127; address++) {
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0) {
Serial.print("I2C device found at address 0x");
if (address < 16)
Serial.print("0");
Serial.print(address, HEX);
Serial.println(" !");
nDevices++;
}
}
if (nDevices == 0)
Serial.println("No I2C devices found\n");
else
Serial.println("Done\n");
delay(5000);
}
and get to following output.
Scanning...
I2C device found at address 0x53 !
Done
Swapped out multiple jumper cables and confirmed confirmed continuity with my multimeter.
Am I missing something simple/key?
Thanks!