Problems with ADXL345 Accelerometer outputs

Hello friends

I am a beginner in Arduino. I bought an Arduino Uno and ADXL345 3-Axis accelerometer. I copied its code, but it gives me the outputs as shown in the attached picture. Does anybody know what the problem is? It’s because of the code or installation? It should give me the acceleration data in X, Y and Z directions, but it gives me only the question mark. Thanx

Below is the code that I used:

#include <Wire.h>

#define DEVICE (0x53) // ADXL345 device address when the SDO pin (12) is grounded

void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(115200); // start serial for output

// Wake up the accelerometer
Wire.beginTransmission(DEVICE); // Start talking to the ADXL345 accelerometer on the SEN-10183 board: http://www.sparkfun.com/products/10183
Wire.write(0x2D); // The address on the accel we want to set: POWER_CTL
Wire.write(8); // The value on the address: Measure(8)
Wire.endTransmission();
}

void loop()
{
// Ask the accel to send us it’s XYZ values
Wire.beginTransmission(DEVICE); // Start talking to the ADXL345 accelerometer on the SEN-10183 board: http://www.sparkfun.com/products/10183
Wire.write(0x32); // The address on the accel we want to read
Wire.endTransmission();

// Receive the XYZ values
Wire.requestFrom(DEVICE, 6);
byte data[6];
for (int i=0;i<6 && Wire.available();i++) {
data = Wire.read();

  • }*
  • Wire.endTransmission();*
  • // Parse them*
  • int x = data[0] | (((int)data[1])<<8);*
  • int y = data[2] | (((int)data[3])<<8);*
  • int z = data[4] | (((int)data[5])<<8);*
  • char buf[100];*
  • sprintf(buf, “x:%d, y:%d, z:%d\r\n”, x,y,z);*
  • Serial.print(buf);*
  • delay(200);*
    }
    Thank u so much in advance