i am trying to connect the Adafruit ADXL377 breakout to the arduino uno and get it read the axis and convert the values into g-force however i am having some trouble. Ive included my code below and would appreciate any help that can be provided. The code runs and works but the output values as like -250 in x-axis , -90 in y axis and -150 in z axis . Obviously when the accelerometer is flat on the table the axis should read 0,0,1 since the only g force being provided is that of gravity on the z access. My circuit is simply and basically i have each axis connected to an analog pin then the vin of the accelerometer connected to the 3.3 on the arduino and gnd to gnd
// these constants describe the pins. They won't change:
const int xpin = A3; // x-axis of the accelerometer
const int ypin = A2; // y-axis
const int zpin = A1; // z-axis (only on 3-axis models)
void setup()
{
// initialize the serial communications:
Serial.begin(9600);
}
void loop()
{
int X = analogRead(xpin);
int Y = analogRead(ypin);
int Z = analogRead(zpin);
// multiple by (3.3/1024)
float Volt_X = X * 0.003222656;
float Volt_Y = Y * 0.003222656;
float Volt_Z = Z * 0.003222656;
float Cal_X = (Volt_X - 1.65)*1000.0;
float Cal_Y = (Volt_Y - 1.65)*1000.0;
float Cal_Z = (Volt_Z - 1.65)*1000.0;
float G_X = (Cal_X/6.5);
float G_Y = (Cal_Y/6.5);
float G_Z = (Cal_Z/6.5);
float Total_Gs = sqrt(sqrt(G_X)+ sqrt(G_Y) + sqrt(G_Z));
Serial.print(G_X);
Serial.print("\t");
Serial.print(G_Y);
Serial.print("\t");
Serial.print(G_Z);
Serial.print("\t");
Serial.println ();
delay(100);
}