I am using Arduino Uno and ADXL345 to detect free fall movement as a part of my project.
This is my pin connection
ADXL345 UNO
INT1 - D2
VCC , CS - 3.3v
SCL - A5
SDA - A4
This is my sample code.
#include <Wire.h>
#include <ADXL345.h>
ADXL345 adxl; //variable adxl is an instance of the ADXL345 library
void setup(){
Serial.begin(9600);
adxl.powerOn();
adxl.setFreeFallThreshold(10);
adxl.setFreeFallDuration(10);
adxl.setInterruptMapping( ADXL345_INT_FREE_FALL_BIT,ADXL345_INT1_PIN );
adxl.setInterrupt( ADXL345_INT_FREE_FALL_BIT, 1);
}
void loop(){
int x,y,z;
adxl.readAccel(&x, &y, &z);
Serial.print(x);
Serial.print("\t");
Serial.print(y);
Serial.print("\t");
Serial.println(z);
byte interrupts = adxl.getInterruptSource();
// freefall
if(adxl.triggered(interrupts, ADXL345_FREE_FALL)){
Serial.println("freefall");
}
delay(100);
}
I set the threshold value as 10, as a test value. I want to figure out the exact threshold value for a fall movement. But I cannot find the relationship between my test threshold value and x,y,z data from the sample data set I got(mentioned below).
I got a sample data set for the movement of Standing up from the sitting position.
x y z
78 16 194
72 10 213
36 6 271
71 -18 281
0 31 258
12 28 269
15 22 221
40 12 168
Freefall
30 18 103
Freefall
29 12 152
Freefall
45 -6 160
57 -22 215
13 13 205
71 -16 190
45 -12 209
I did some Google searching but didn't find any explanation. Could you please explain the relation between my x,y,z data and my test threshold value?