Hey,

I'm trying to use the ADXL345 to detect the tilt of the PCB. But it seems fluctuate too much.

I'm initializing the accelerometer as +/-2G range, with full resolution disabled and FIFO bypassed. At the beginning I'm trying to use the activity feature and set the threshold to 1(62.5mg), then I found the activity interrupt is always triggered. If I configure the threshold to a larger one like 8, it won't be triggered till the corresponding larger angle.

I have below log and it's showing the value of each axis is fluctuating in like around 2degrees. Can I get any suggestion to make it more stable and do you know how much accuracy of degrees I can count on the ADXL345? Thank you so much!

ADXL::X->-010(-2.258), Y->-018(-4.066), Z->0253 ADXL::X->-009(-2.048), Y->-019(-4.326), Z->0251 ADXL::X->-008(-1.809), Y->-013(-2.940), Z->0253 ADXL::X->-015(-3.448), Y->-022(-5.060), Z->0248 ADXL::X->-009(-2.024), Y->-019(-4.275), Z->0254 ADXL::X->-009(-2.024), Y->-019(-4.275), Z->0254 ADXL::X->-009(-2.024), Y->-019(-4.275), Z->0254 ADXL::X->-008(-1.808), Y->-016(-3.617), Z->0253 ADXL::X->-014(-3.145), Y->-020(-4.495), Z->0254 ADXL::X->-006(-1.361), Y->-016(-3.632), Z->0252 ADXL::X->-012(-2.697), Y->-019(-4.273), Z->0254 ADXL::X->-009(-2.025), Y->-017(-3.827), Z->0254 ADXL::X->-009(-2.025), Y->-017(-3.827), Z->0254 ADXL::X->-009(-2.025), Y->-017(-3.827), Z->0254 ADXL::X->-012(-2.719), Y->-019(-4.307), Z->0252 ADXL::X->-013(-2.891), Y->-014(-3.114), Z->0257 ADXL::X->-014(-3.133), Y->-020(-4.478), Z->0255 ADXL::X->-014(-3.158), Y->-019(-4.288), Z->0253 ADXL::X->-009(-2.003), Y->-014(-3.116), Z->0257 ADXL::X->-005(-1.130), Y->-014(-3.167), Z->0253 ADXL::X->-005(-1.130), Y->-014(-3.167), Z->0253 ADXL::X->-014(-3.134), Y->-019(-4.255), Z->0255 ADXL::X->-010(-2.251), Y->-015(-3.377), Z->0254 ADXL::X->-011(-2.501), Y->-020(-4.551), Z->0251 ADXL::X->-010(-2.258), Y->-018(-4.066), Z->0253 ADXL::X->-009(-2.040), Y->-018(-4.083), Z->0252 ADXL::X->-009(-2.040), Y->-018(-4.083), Z->0252 ADXL::X->-009(-2.040), Y->-018(-4.083), Z->0252 ADXL::X->-011(-2.492), Y->-019(-4.308), Z->0252 ADXL::X->-013(-2.932), Y->-020(-4.514), Z->0253 ADXL::X->-010(-2.257), Y->-019(-4.291), Z->0253 ADXL::X->-005(-1.135), Y->-013(-2.953), Z->0252 ADXL::X->-011(-2.465), Y->-017(-3.811), Z->0255 ADXL::X->-011(-2.465), Y->-017(-3.811), Z->0255 ADXL::X->-011(-2.465), Y->-017(-3.811), Z->0255 ADXL::X->-006(-1.372), Y->-016(-3.661), Z->0250 ADXL::X->-011(-2.494), Y->-017(-3.856), Z->0252 ADXL::X->-009(-2.041), Y->-017(-3.857), Z->0252 ADXL::X->-010(-2.267), Y->-018(-4.082), Z->0252 ADXL::X->-010(-2.267), Y->-018(-4.082), Z->0252

And below is the initializing configuration for the accelerometer.

ADXL345_SetPowerMode(0); ADXL345_SetRegisterValue(ADXL345_DATA_FORMAT, ADXL345_RANGE(ADXL345_RANGE_PM_2G)); ADXL345_SetRegisterValue(ADXL345_FIFO_CTL, ADXL345_FIFO_MODE(ADXL345_FIFO_BYPASS)); ADXL345_SetRegisterValue(ADXL345_BW_RATE, ADXL345_RATE(ADXL345_6HZ25)); ADXL345_SetPowerMode(1); //Once the angle of x/ y exceeds 3.58degree, will assert the interrupt signal-2. ADXL345_SetRegisterValue(ADXL345_THRESH_ACT, 1); //around 3.58degree. ADXL345_SetRegisterValue(ADXL345_ACT_INACT_CTL, ADXL345_ACT_X_EN | ADXL345_ACT_Y_EN); ADXL345_SetRegisterValue(ADXL345_INT_MAP, ADXL345_ACTIVITY); ADXL345_GetRegisterValue(ADXL345_INT_SOURCE); ADXL345_SetRegisterValue(ADXL345_INT_ENABLE, ADXL345_ACTIVITY);