Hi, I am using ADXL373Z accelerometer with Arduino Uno for a project.
When I run the code, I am getting incorrect values which are probably not even acceleration data. I am thinking it might be a wiring problem, I attached circuit diagram below. This is my first Arduino project, and I couldn't find any other applications with the sensor I am using so any help would be much appreciated. Thanks in advance.
Datasheet for sensor : https://www.analog.com/media/en/technical-documentation/data-sheets/adxl373.pdf
Code ( for x-axis data only) :
// ADXL373 Accelerometer Test
#include <Wire.h>
/* -------- REGISTERS -------- */
#define ADDRESS_ADXL373 0x53 // sensor adress (assumes MISO pin high)
#define ADDRESS_POWER_CTL 0x3F // power control
#define ADDRESS_MEASURE 0x0E // measurement control
#define ADDRESS_TIMING 0x3D // output data rate and extarnal timing triggers
#define ADDRESS_XDATA_H 0x08 // x-axis acceleration data [11:4]
#define ADDRESS_XDATA_L 0x09 // x-axis acceleration data [3:0]
#define ADDRESS_YDATA_H 0x0A // y-axis acceleration data [11:4]
#define ADDRESS_YDATA_L 0x0B // y-axis acceleration data [3:0]
#define ADDRESS_ZDATA_H 0x0C // z-axis acceleration data [11:4]
#define ADDRESS_ZDATA_L 0x0D // z-axis acceleration data [3:0]
/* -------- REGISTERS -------- */
void setup() {
Serial.begin(115200);
while(!Serial);
Serial.println("ADXL373 Accelerometer Test");
Wire.begin();
Wire.beginTransmission(ADDRESS_ADXL373);
Wire.write(ADDRESS_POWER_CTL);
Wire.write(0x03); // activate full bandwith measurement mode
Wire.endTransmission(true);
delay(50);
Wire.beginTransmission(ADDRESS_ADXL373);
Wire.write(ADDRESS_MEASURE);
Wire.write(0x04); // set output signal bandwith to 2560 Hz
Wire.endTransmission(true);
delay(50);
Wire.beginTransmission(ADDRESS_ADXL373);
Wire.write(ADDRESS_TIMING);
Wire.write(0x80); // set output data rate to 5120 Hz
Wire.endTransmission(true);
delay(50);
}
void loop() {
byte xAxisH, xAxisL;
Wire.beginTransmission(ADDRESS_ADXL373);
Wire.write(ADDRESS_XDATA_H);
Wire.endTransmission(false);
Wire.requestFrom(ADDRESS_ADXL373, 1, true);
xAxisH = Wire.read();
Wire.beginTransmission(ADDRESS_ADXL373);
Wire.write(ADDRESS_XDATA_L);
Wire.endTransmission(false);
Wire.requestFrom(ADDRESS_ADXL373, 1, true);
xAxisL = Wire.read();
int16_t xAxisFinal;
xAxisFinal = xAxisH << 4 | xAxisL; // bit shift 12-bit output data
Serial.print("Xa = ");
Serial.println(xAxisFinal);
delay(200);
}
Circuit Diagram :