I am using an ADXL345 sensor connected via I2C to an Arduino Mega2560. I am using the built-in Adafruit libraries and the example also supplied in the IDE.
It works, but I found that I have to (a) set the scale to 16G, and (b), adjust the values as follows:
X = (X+2.2)/12.8
Y = (Y+6.3)/12.9
Z = (Z-47)/11
Any idea why that is? Am I doing something wrong? I checked other posts but cannot find the same issue, though I do see it elsewhere online (but without solutions).
For accurate measurements, all sensors require calibration. Most people find that with MEMS accelerometers, each axis requires a scale and offset factor, but more sophisticated calibration approaches are available.
The datasheet gives the various accuracy and precision data. In particular the basic sensitivity variation is spec'd to be +/-1% for X,Y,Z, and they should have
the same sensitivity.
You calibration data suggests the Z axis is very different to X and Y, which suggests the device is not conforming to the datasheet for the ADXL345 - perhaps its counterfeit??
The datasheet says the Z axis is a little different in noise and offset tolerance, but doesn't suggest the 12.8 : 11 sensitivity ratio you seem to observe.
Well, I thought the same: it might be counterfeit - was cheap. But after my math, it does work consistently;y, so in the end, no harm done. Other than the time I lost working this out from scratch