Problem with reading ADXL345 registers

I have problems while reading the 0x00 register, which contains the device ID of 0xE5(345 Octal)
Whats wrong in the code.
Hope that i am not making any blunder
Thanks in advance.

#define addr 0x53
int x;
void setup() 

void loop() {
  // put your main code here, to run repeatedly:

      x =;



Is your ALT_ADDRESS pin pulled up or down?

Change the line




to omit the stop condition on the bus between the write and the read.

I tried the same code for HMC5883L Compass, but it is also showing '0' on serial monitor. I also have changed the code as you said but it is still not working. Waiting for your reply

Post a wiring diagram! What type of Arduino are you using?

I am using Arduino Uno.

The circuit Diagram of HMC5883L is;


The HMC5883L is a 3V3 chip. Connecting it directly to 5V probably fried it.

BTW, same applies for the ADXL345.

Sir i have connected to 3.3v of arduino. still it is not working

You may have it powered by the UNO 3.3V pin. What voltage levels do you think are produced by the A4/A5 SDA/SCL of the 5V Arduino UNO connected to the 3.3V ADXL345 chip?

Sir i have read its three output registers they are working perfectly only issue is that the Identify registers are not giving their fixed values

That's new information. You posted in a such a way that led us to believe you couldn't read anything from the chip. If you can read something, then reading this particular register relies on you understanding the datasheet.

Also, if the UNO is 5V then the SDA/SCL lines are 5V. It is liekly only a matter of time before the chip dies due to over voltage.

thanx for helping sir