How do you intend to convert acceleration into velocity? Post some code, using code tags, and I’ll use it to explain the issue.
My first idea is to use this formula,
Can I use this formula to find velocity?
g * (9807) / (2PIF) = v
But i got two unknown the F and v. And after reading around, this is not the correct method
/*-----( Import needed libraries )-----*/
#define DEVICE (0x53) //ADXL345 device address
#define TO_READ (6) //num of bytes we are going to read each time (two bytes for each axis)
#define THRESH_ACT (0x24)
#define THRESH_INACT (0x25)
byte buff[TO_READ] ; //6 bytes buffer for saving data read from the device
char str; //string buffer to transform data before sending it to the serial port
// Declare Variable
float x, y, z; //Acceleration variable
float x1, y1, z1; //Acceleration variable
int regAddress = 0x32; //first axis-acceleration-data register on the ADXL345
readFrom(DEVICE, regAddress, TO_READ, buff); //read the acceleration data from the ADXL345
//each axis reading comes in 10 bit resolution, ie 2 bytes. Least Significat Byte first!!
//thus we are converting both bytes in to one int
x = (((int)buff) << 8) | buff;
y = (((int)buff)<< 8) | buff;
z = (((int)buff) << 8) | buff;
x1 = x/256 *9807;
y1 = y/256 *9807;
z1 = z/256 *9807;
Serial.print("X: ");Serial.print(x1); Serial.println(" mm/s2");
Serial.print("Y: ");Serial.print(y1); Serial.println(" mm/s2");
Serial.print("Z: ");Serial.print(z1); Serial.println(" mm/s2");
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600); // start serial for output
writeTo(DEVICE, 0x2D, 0); //Turning on the ADXL345
writeTo(DEVICE, 0x2D, 16); //Turning on the ADXL345
writeTo(DEVICE, 0x2D, 8); //Turning on the ADXL345
delay(2000); //It appears that delay is needed in order not to clog the port
This is my code now.
Thank you so much!