Couldn't get a calibrated value for ADXL 345 accelerometer

i measured min and max points according this link. Programming and Calibration | ADXL345 Digital Accelerometer | Adafruit Learning System

got those :
21:45:08.028 -> Accel Minimums: -15.73 -15.85 0.00
21:45:08.028 -> Accel Maximums: 8.47 7.65 63.59

my code:

  Serial.print("X: "); Serial.print((((event.acceleration.x - (-15.73))* 19.62)/8.47) + (-9.81) ); Serial.print("  ");
  Serial.print("Y: "); Serial.print((((event.acceleration.y - (-15.85))* 19.62)/7.65) + (-9.81) ); Serial.print("  ");
  Serial.print("Z: "); Serial.print((((event.acceleration.z)* 19.62)/63.59) + (-9.81) ); Serial.print("  ");Serial.println("m/s^2 ");

still having uncalibrated measurments , where am i making a mistake ? Thanks.

Please use code tags when posting code.

You have not applied the offsets or scale correctly, so please re-read the instructions in the tutorial. Remove the "-9.81" term. It should not be there.

Serial.print("X: "); Serial.print((((event.acceleration.x - (-15.73))* 19.62)/8.47) + (-9.81) );

This is a better description of the "six point" calibration method.

Those numbers are WAY off. After measuring in all 6 directions the maximums should be close to 1.00 and minimums should be close to -1.00. Even if the scale factor is bad the readings should be +/-N for all three axes since all three are measuring the same acceleration due to gravity.

Try doing the readings again. Repeat until you get reasonable readings.

made about 60-100 measurements, best i can do is :

23:12:59.199 -> Accel Minimums: -15.85 -16.04 0.00
23:12:59.245 -> Accel Maximums: 8.71 7.73 64.06

i don't understand why, how about i try one point scaling, or a different wiring ? Thanks

You should be making SIX measurements. For each measurement, the axis that is vertical should show a value close to 1.00 or -1.00. The other two axes are horizontal and should read near 0.

Follow the link you posted. Start at "Calibration Method:" and work through the steps.

i know, i mean i made six measurements for each ten, fifteen set of measurements according to link that i posted. but nothing changes.

You are probably making a mistake (or two).

Post the code you used to make the measurements, using code tags please. You should be reading the RAW accelerometer values. Those will be integers and won't look anything like the numbers you posted.

If you are getting results that far from normal (+1, -1) I would suspect that you accelerometer has been broken by severe impact. Time to buy a new one.

i am using the basic code given at the link

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_ADXL345_U.h>

/* Assign a unique ID to this sensor at the same time */
Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified(12345);

float AccelMinX = 0;
float AccelMaxX = 0;
float AccelMinY = 0;
float AccelMaxY = 0;
float AccelMinZ = 0;
float AccelMaxZ = 0;

void setup(void) 
  Serial.println("ADXL345 Accelerometer Calibration"); 
  /* Initialise the sensor */
    /* There was a problem detecting the ADXL345 ... check your connections */
    Serial.println("Ooops, no ADXL345 detected ... Check your wiring!");

void loop(void)
    Serial.println("Type key when ready..."); 
    while (!Serial.available()){}  // wait for a character
    /* Get a new sensor event */ 
    sensors_event_t accelEvent;  
    if (accelEvent.acceleration.x < AccelMinX) AccelMinX = accelEvent.acceleration.x;
    if (accelEvent.acceleration.x > AccelMaxX) AccelMaxX = accelEvent.acceleration.x;
    if (accelEvent.acceleration.y < AccelMinY) AccelMinY = accelEvent.acceleration.y;
    if (accelEvent.acceleration.y > AccelMaxY) AccelMaxY = accelEvent.acceleration.y;
    if (accelEvent.acceleration.z < AccelMinZ) AccelMinZ = accelEvent.acceleration.z;
    if (accelEvent.acceleration.z > AccelMaxZ) AccelMaxZ = accelEvent.acceleration.z;
    Serial.print("Accel Minimums: "); Serial.print(AccelMinX); Serial.print("  ");Serial.print(AccelMinY); Serial.print("  "); Serial.print(AccelMinZ); Serial.println();
    Serial.print("Accel Maximums: "); Serial.print(AccelMaxX); Serial.print("  ");Serial.print(AccelMaxY); Serial.print("  "); Serial.print(AccelMaxZ); Serial.println();

    while (Serial.available())
    {;  // clear the input buffer

i changed the wiring and got these final measurements
00:04:15.005 -> Accel Minimums: -15.89 -16.04 0.00
00:04:15.051 -> Accel Maximums: 9.30 7.61 20.04

current circuit:
VCC - 5V

and i don't think it's broken because i recently bought it and first time using.

I really dislike and recommend to avoid the bloated Adafruit libraries, because they attempt to scale the data without knowing the corrections required for your particular unit.

Remove those libraries and try another. You might consider the Sparkfun or the gabriel-ns library.

In either case, MAKE SURE that you are reading the RAW accelerometer values, not scaled values. For the Sparkfun library, follow the hookup guide and use this routine to get the RAW data:

ADXL345::readAccel(int *x, int *y, int *z)

i used Sparkfun library calibration code, followed the steps mentioned and i obtained
New Calibrated Values: 0 9 9
so the question: what i am going to with these ?

Those look bogus. If your block is resting on one of its sides, one axis should read +1g or -1g and the other two should read 0g. NONE should read 9g.

What Accel Minimums and Accel Maximums do you get after taking a single measurement on all 6 sides?

so the question: what i am going to with these ?

Nothing, because those values make no sense.

Help us help you. Please post the RAW accelerometer data, from the Sparkfun library, for EACH of the six calibration orientations.

For example:
"Z pointing up" x, y, z values
"Z pointing down" x, y, z values
"Y pointing up" x, y, z values

Sorry for being this painful,

"Z pointing up" -13, -16, 202
"Z pointing down" -12, -13, 134
"X pointing up" 27, -13, 169
"X pointing down" -51, -14, 169
"Y pointing up" -13, 24, 173
"Y pointing down" -12, -51, 169

Also, sparkfun calibration script, From top to below --> (+Z,-Z,+X,-X,+Y,-Y)

20:33:52.642 -> SparkFun ADXL345 Accelerometer Breakout Calibration
20:33:52.642 -> 
20:33:52.642 -> Send any character to display values.
20:34:12.910 -> 
20:34:12.910 -> Accel Minimums: -101  -130  0
20:34:12.960 -> Accel Maximums: 0  0  511
20:34:12.960 -> 
20:34:12.960 -> Send any character to display values.
20:34:21.123 -> 
20:34:21.123 -> Accel Minimums: -101  -130  0
20:34:21.172 -> Accel Maximums: 0  0  511
20:34:21.172 -> 
20:34:21.172 -> Send any character to display values.
20:34:28.192 -> 
20:34:28.192 -> Accel Minimums: -101  -130  0
20:34:28.241 -> Accel Maximums: 212  0  511
20:34:28.241 -> 
20:34:28.286 -> Send any character to display values.
20:34:33.706 -> 
20:34:33.706 -> Accel Minimums: -402  -130  0
20:34:33.755 -> Accel Maximums: 212  0  511
20:34:33.755 -> 
20:34:33.755 -> Send any character to display values.
20:34:51.724 -> 
20:34:51.724 -> Accel Minimums: -402  -130  0
20:34:51.772 -> Accel Maximums: 212  194  511
20:34:51.772 -> 
20:34:51.772 -> Send any character to display values.
20:34:57.628 -> 
20:34:57.628 -> Accel Minimums: -402  -405  0
20:34:57.677 -> Accel Maximums: 212  194  511
20:34:57.718 -> 
20:34:57.718 -> Send any character to display values.

by the way my circuit is slightly different from shown at Sparkfun page. My circuit only consists:
GND - GND , VCC - 5V ,SCL - SCL , SDA -SDA , nothing else.

The sensor is clearly not working correctly, as the Z axis reading is always large and positive regardless of orientation. It is either defective or has been damaged.

Please post a link to the breakout board are you using.

Note that the sensor chip is 3.3V MAXIMUM, and you should have level shifters on the I2C lines, when used with a 5V Arduino. Best to use a 3.3V Arduino with a 3.3V sensor, then there are no voltage mismatch worries.

i changed 5V to 3.3V and redid the previous raw data measurement just to be sure. But nothing changed. My breakout:

Also broken Z axis is not a big problem for me, i only need one horizontal axis to be calibrated.

Is it too much trouble to post a link to the sensor module?

i changed 5V to 3.3V

The damage has already been done.

It is not clear that the X or Y axes are working. If you have chosen the +/- 2g scale, you would expect much larger numbers in those positions (e.g. roughly 250 and -250 for up and down, respectively).

it is on range 16g.
i thought you asked the circuit. sensor module page is in another language clearly you wouldn't understand but it says 2V - 3.6V for range.
Let's assume they working even if they don't i only need a data range. so what should i do, this already took so long can you paste me a suitable code?

Good luck with your project.

probably most toxic forum i have ever been. homeboy thinks he can speak japanese meanwhile not being able to communicate for 3 days with thinking i am in his mind, knowing what he is trying to tell me. Probably you are a 13 year old who considers himself as real Tony Stark. Yeah you the best. You really should consider not everyone has knowledge about every topic in this universe yet again time learn those from the zero. But in life sometimes you have to work outer discipline :smiley: . The Life my dude, which you don't have i guess...

also sharing a code, just 15 lines of code is worth more than 3 days of nonsense with you.

i was not gonna flag you. You don't need to edit your toxic message to save your personality from getting banned.