ADXL337 Accelerometer Readings Incorrect

Hello, I'm, using the ADXL337 for a project and I have the wiring diagram attached below.

But when I run the code, I am getting values that are incorrect. Here is the code:
I am using Arduino Uno, with no libraries.

// Make sure these two variables are correct for your setup
int scale = 3; // 3 (±3g) for ADXL337, 200 (±200g) for ADXL377
boolean micro_is_5V = true; // Set to true if using a 5V microcontroller such as the Arduino Uno, false if using a 3.3V microcontroller, this affects the interpretation of the sensor data

void setup()
{
  // Initialize serial communication at 115200 baud
  Serial.begin(115200);
}

// Read, scale, and print accelerometer data
void loop()
{
  // Get raw accelerometer data for each axis
  int rawX = analogRead(A0);
  int rawY = analogRead(A1);
  int rawZ = analogRead(A2);
  
  // Scale accelerometer ADC readings into common units
  // Scale map depends on if using a 5V or 3.3V microcontroller
  float scaledX, scaledY, scaledZ; // Scaled values for each axis
  if (micro_is_5V) // Microcontroller runs off 5V
  {
    scaledX = mapf(rawX, 0, 675, -scale, scale); // 3.3/5 * 1023 =~ 675
    scaledY = mapf(rawY, 0, 675, -scale, scale);
    scaledZ = mapf(rawZ, 0, 675, -scale, scale);
  }
  else // Microcontroller runs off 3.3V
  {
    scaledX = mapf(rawX, 0, 1023, -scale, scale);
    scaledY = mapf(rawY, 0, 1023, -scale, scale);
    scaledZ = mapf(rawZ, 0, 1023, -scale, scale);
  }
  
  // Print out raw X,Y,Z accelerometer readings
  Serial.print("X: "); Serial.println(rawX);
  Serial.print("Y: "); Serial.println(rawY);
  Serial.print("Z: "); Serial.println(rawZ);
  Serial.println();
  
  // Print out scaled X,Y,Z accelerometer readings
  Serial.print("X: "); Serial.print(scaledX); Serial.println(" g");
  Serial.print("Y: "); Serial.print(scaledY); Serial.println(" g");
  Serial.print("Z: "); Serial.print(scaledZ); Serial.println(" g");
  Serial.println();
  
  delay(2000); // Minimum delay of 2 milliseconds between sensor reads (500 Hz)
}

// Same functionality as Arduino's standard map function, except using floats
float mapf(float x, float in_min, float in_max, float out_min, float out_max)
{
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

I have attached the serial monitor readings.
But whenever I move the sensor, the reading don't change and are constant. Please let me know if you need any extra information, and I'd be happy to provide. I did look up this problem, but couldn't find much on it. Please let me know if you have a solution, or any advice! Thanks!

Why did you declare it as an int?

  int rawX = analogRead(A0);[color=#222222][/color]
  int rawY = analogRead(A1);[color=#222222][/color]
  int rawZ = analogRead(A2);

Look at the raw values, they are stuck to 1023, which is for 5V.
That is impossible, because there is no 5V going to the sensor.

That means that something else is wrong.
Perhaps the analog section of the microcontroller (inside in the chip die) is broken.
Perhaps the AREF pin is connected to something. Can you check the board with a magnifier near the AREF pin ? Are there solder blobs or shortcuts ?
Perhaps something else is going on.

Can you disconnect everything, and show the analog value on the serial monitor and move your finger over the plastic strip of the analog pins. You should see them change. If they don't, then try another Arduino board.

dyso:
Why did you declare it as an int?

  int rawX = analogRead(A0);[color=#222222][/color]

int rawY = analogRead(A1);
 int rawZ = analogRead(A2);

So I can read the values in the serial monitor.

I suspect a wiring problem. Double check it, or move every connection to a new place on the breadboard.

Did you solder header pins to the module, correctly, with no shorts or bad connections?

jremington:
I suspect a wiring problem. Double check it, or move every connection to a new place on the breadboard.

Did you solder header pins to the module, correctly, with no shorts or bad connections?

Yes I soldered the header pins to my PCB Arduino shield, and I checked the file for the PCB and the connections look correct. Let me try reading voltage from the pins…

Koepel:
Look at the raw values, they are stuck to 1023, which is for 5V.
That is impossible, because there is no 5V going to the sensor.

That means that something else is wrong.
Perhaps the analog section of the microcontroller (inside in the chip die) is broken.
Perhaps the AREF pin is connected to something. Can you check the board with a magnifier near the AREF pin ? Are there solder blobs or shortcuts ?
Perhaps something else is going on.

Can you disconnect everything, and show the analog value on the serial monitor and move your finger over the plastic strip of the analog pins. You should see them change. If they don’t, then try another Arduino board

There doesn’t seem to be any solder or problems with the AREF pin. I tried the finger method and the values changed, so I believe the board is fine. I tried with an Arduino Mega and the same issue occured.

It doesn’t add up.
If the analog inputs can measure noise from a nearby finger, then they are allright and not broken.
If you get 1023 from a sensor which is only connected to 3.3V, that is not even possible.

There seems to be more problems lately with broken jumper wires on this forum. Can you test if the GND, 3.3V, SDA and SCL really are connected to the sensor and the Arduino ? Can you make a photo of it ?

Do you have another sensor ?
Are you sure that the sketch you have showed us is the sketch that you used ?

What is a "PCB Arduino shield"?

Post a clear, focused photo of your setup.

It is a PCB that goes directly on top of the Arduino. I did figure it out. There was a piece of metal stuck in one of the pins, and I took it out and got the right readings. Thanks for the help!

Thanks for the update. It can happen to us as well. I'm glad you found the problem. I think you are in luck that the sensor is still working.