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.