Calibration of ADXL377- ASAP

Hello everyone,

I am currently working with Arduino Uno and ADXL377.
I am using the the Sparkfun hookup guide program.

int scale = 200;
boolean micro_is_5V = true;
void setup()
{
// Initialize serial communication at 115200 baud
Serial.begin(115200);
}

void loop()
{
// Get raw accelerometer data for each axis
int rawX = analogRead(A0);
int rawY = analogRead(A1);
int rawZ = analogRead(A2);

float scaledX, scaledY, scaledZ; // Scaled values for each axis
if (micro_is_5V) // microcontroller runs off 5V
{
scaledX = map(rawX, 0, 675, -scale, scale);// 3.3/5 * 1023 =~ 675
scaledY = map(rawY, 0, 675, -scale, scale);
scaledZ = map(rawZ, 0, 675, -scale, scale);
}
else // microcontroller runs off 3.3V
{
scaledX = map(rawX, 0, 1023, -scale, scale);
scaledY = map(rawY, 0, 1023, -scale, scale);
scaledZ = map(rawZ, 0, 1023, -scale, scale);
}

// Print out raw X,Y,Z accelerometer readings

Serial.print("X: "); Serial.println(rawX);
Serial.print("Y: "); Serial.println(rawY);
Serial.print("Z: "); Serial.println(rawZ);

// Print out scaled X,Y,Z accelerometer readings
Serial.print(ā€œX: ā€œ); Serial.print(scaledX); Serial.println(ā€ gā€);
Serial.print(ā€œY: ā€œ); Serial.print(scaledY); Serial.println(ā€ gā€);
Serial.print(ā€œZ: ā€œ); Serial.print(scaledZ); Serial.println(ā€ gā€);

delay(200);
}

I am somehow not able to calibrate it. I have used

for calibration.

Following is the output I am getting from the program.

X: 513
Y: 513
Z: 518
X: 104.00 g
Y: 104.00 g
Z: 106.00 g
X: 513
Y: 513
Z: 518
X: 104.00 g
Y: 104.00 g
Z: 106.00 g
X: 399
Y: 397
Z: 425
X: 36.00 g
Y: 35.00 g
Z: 51.00 g
X: 513
Y: 513
Z: 518
X: 104.00 g
Y: 104.00 g
Z: 106.00 g
X: 513
Y: 513
Z: 518
X: 104.00 g
Y: 104.00 g
Z: 106.00 g

This is when the sensor is in steady state.
Can anyone please help me. I am fairly new to this platform.

I miss the link to the exact breakout board you're using and a wiring diagram.

When the sensor is held still, the acceleration along any vertical axis is exactly 1.000 g. You need to find one offset and one scale factor per axis that produces that value.

"Not able to calibrate it" tells us nothing.

Thank you for your response.
Following is the link to the breakout board of adxl377.

for the above breakout the connections which I did were following

Arduino Uno ADXL377
5V Vin
Gnd GND
A0 X
A1 Y
A2 Z
Aref 3.3

Thank you for your response.

By not able to calibrate I mean .

That even in the steady position , lying flat on the table the accelerometer is giving the same reading.

where x,y,z are 104.6 g
when I try to move the accerometer there is no significant change.

Sorry, I did not notice you are using the ADXL377, which is 200 g full scale.

That particular accelerometer is used for estimating acceleration during, for example automobile crashes, and is not useful for measuring accelerations of 1 or 2 g.

Unless you have access to a some means of generating a known large acceleration, don't bother trying to calibrate it.

1 Like

ok ok ..
Thanks for the response.
Helped me understand better.

AREF is not used in your code. So you cannot use the full 1023 steps of the ADC. Tip: check this reference page.