Constant Z-Axis Value on ADXL345 at 2g Range

Discussion created by vedantp on Mar 17, 2016



I am using an ADXL345 Accelerometer for a Tilt Sensing application.

The Z-Values at the 2g range seem to be locked on a single value (511 in decimal).

4g, 8g and 16g ranges work perfectly (but with lower sensitivities).


Ive followed recommendations on the datasheet and played around quite a bit with Power Modes, Data Rates, Communication Protocols, etc. but to no avail.


I see there are already several questions asked for the same problem, but no solutions were there in the answers. (they mostly tried changes in initialization, power, etc...but that isnt the problem. neither is soldering or chip damage)


Below is how i extract the value of Z Axis:


char POWER_CTL = 0x2D;  //Power Control Register

char DATA_FORMAT = 0x31;

char FIFO_CTL = 0x38;

char BW_RATE = 0x2C; //tried all data rates from 100 to 1600Hz


char DATAZ0 = 0x36; //Z-Axis Data 0

char DATAZ1 = 0x37; //Z-Axis Data 1


//The ADXL345 gives 10-bit acceleration values, but they are stored as bytes (8-bits). To get the full value, two bytes must be combined for each axis.

//The X value is stored in values[0] and values[1].


//The Z value is stored in values[4] and values[5].

  z = ((int)values[5]<<8)|(int)values[4];


Serial.print(x, DEC); // is giving me 511 continuously. Other Axes work fine and in range as expected.


Would Appreciate any help.