ADXL345 problems when it interfaced with arduino due board

Hello,

I just got my ADXL345 board and started trying to get the accelerometer readings.
I have an Arduino due board, and followed the steps outlined in this blog.

When i interfaced adxl345 with arduino due board with I2C protocol, it gave constant values of position x, y and z.
Like,

pos1
x = -512, y = -512 and z = -1

pos2
x = -512, y = -512 and z = -1

pos3
x = -512, y = -512 and z = -1

pos4
x = -512, y = -512 and z = -1

When i changed position of adxl345, i can't get different values. I still got values which are mentioned above. I attached I2C based code and connections are:

arduino due pins adxl345 pins

Analog A4 SDA
Analog A5 SCL
Gnd Gnd and SDO
3.3 V pin Vcc and CS

Please someone give a response about it as soon as possible and help me.
Give a proper code and connections, if there are changes in it.

i2c_3.txt (2.19 KB)

Please search the forum for similar threads.