Hi I'm using Arduno Uno and ADXL345 to detect free fall. I have come up to here in my coding.
#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(5); //(5 - 9) recommended - 62.5mg per increment
adxl.setFreeFallDuration(20); //(20 - 70) recommended - 5ms per increment
//setting all interupts to take place on int pin 1
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);
}
When the accelerometer in in a still position my x,y,z readings are as follows 2,-121,206
My question is I don't know what values to set for free-fall threshold and free-fall duration (even thought I have set sample values here). How do I calculate these values?