Got confused on how to read ADXL356 from rawValues to g when connected to Teensy4.1

I tried to convert the raw values to g, so that I can do further analysis like FFT, time domain and time-frequency domain analysis.

I got confused on how to interpret the datasheet as attached.

I don't really know if it is advisable to use the accelerometer timestamp , that is the micros().

const int X_AXIS_PIN = A9;  // Analog input pin for X-axis
const int Y_AXIS_PIN = A8;  // Analog input pin for Y-axis
const int Z_AXIS_PIN = A7;  // Analog input pin for Z-axis

void setup() {
  Serial.begin(2000000);  // Initialize serial communication
}

void loop() {
  int xData, yData, zData;

  // Read analog values from accelerometer
  xData = analogRead(X_AXIS_PIN);
  yData = analogRead(Y_AXIS_PIN);
  zData = analogRead(Z_AXIS_PIN);
  

  // Print the accelerometer data
  //Serial.print("X: ");
  Serial.print(micros());
  Serial.print(",");
  Serial.print(xData);
  Serial.print(",");
  Serial.print(yData);
  Serial.print(",");
  Serial.println(zData);

  //delay(500);  // Delay between readings
}


36984059,228,209,234
36984111,228,209,233
36984164,228,209,234
36984216,228,209,234
36984268,228,209,233
36984321,228,209,233
36984373,228,209,234
36984425,228,209,233
36984478,228,209,234
36984530,228,209,233
36984582,228,208,233
![C84DAF95-6D22-4E41-B326-E8B8FD341B4E|690x373](upload://kN4moN2ZuqgkCMWrbYsHnJxTw7f.jpeg)
![7F80A23D-5955-4882-ADEC-694E2CDF41A8|690x461](upload://XB5YbFE5oL9asjGoM83mKjditO.jpeg)

None of those operations require that you change units of measure. They work on any scale.

But as a hint: if you hold the board still with one axis vertical, it will report 1 g acceleration on that axis, on any selected scale, and zero g on any perfectly horizontal axis.

The scale factor will vary slightly, depending on which axis you choose. Recalibrate the sensor to make them equal, if you like.

Many thanks for your response, so can I use the accelerometer raw values and use the micros() column as my time?

Yes. Keep in mind that to have both positive and negative accelerations, you need to subtract the zero-g reading from each axis.

Before you analyze sensor data, you must fully understand what the raw values mean.

This is a page from the data sheet but I don't really understand how to get the positive and negative acceleration.

Please I am a novice , i got this when the accelerometer was held still.


29973143,222,222,242
29973195,222,222,242
29973247,222,222,242
29973300,222,222,242
29973352,223,222,242
29973404,222,222,242
29973457,222,222,242
29973509,222,222,242
29973561,223,222,242
29973614,222,222,242
29973666,222,222,242
29973718,222,222,242

If X and Y are perfectly horizontal, and Z is up, then the zero g offsets on X and Y are 222 (corresponding to 0 g).

Assuming the same offset for Z, then the raw acceleration on the Z axis is 242-222 = 20 = +1 g.

If that is correct, flip the sensor over, with X and Y still perfectly horizontal, and you should see a reading of 202 along Z (-1 g).

This calibration tutorial is for a digital version of that accelerometer, but may give you some additional insight.

Many thanks for the tutorials, and I have flipped the sensor


111250772,222,222,203
111250824,222,223,203
111250876,222,222,203
111250929,222,222,203
111250981,222,223,203

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.