ADXL 337 calibration

Hi folks,

I’m trying to calibrate my ADXL 337. I used the example code found on the SparkFun tutorial I’m using a 3.3V arduino so boolean micro_is_5V = false; .

These are the ranges that I see for scaling raw data for 3.3V arduino:

scaledX = mapf(rawX, 0, 1023, -scale, scale);

scaledY = mapf(rawY, 0, 1023, -scale, scale);

scaledZ = mapf(rawZ, 0, 1023, -scale, scale);

Currently, when I use these default ranges, my data looks like this:

Raw:

X: 520

Y: 504

Z: 614

Scaled:

X: 0.05 g

Y: -0.04

Z: 0.60 g

My question is: How can I offset the ranges (currently 0, 1023) to calibrate my sensor?

Thank you so much.

-Aidan

Hello,

We don’t currently have a solution for that particular type of calibration. Since it is outside the example code we’ve written we can only give limited support.

Why are you wanting to offset the ranges, and by how much?

Thank you for your response! Currently, the “Scaled” results that I posted above are my readings for the accelerometer when it was upright and level. I understand that X and Y should read “0” and Z should read “1”, however the results that I’m getting are quite a bit off from that, especially for the Z axis. I’m looking to offset X by 0.05g, Y by 0.04g and Z by 0.6g, as indicated in my results above. If there is any support you could offer, I would greatly appreciate it. I did see a comment from someone in the tutorial for this sensor that said it could be calibrated easily.

What do you get for the RAW values if you sample them 3-4 times with some delay in between samples, leaving the board completely still?

Hi again,

Doing that did not change the values. The raw values are still:

X: 520

Y: 504

Z: 614

I’d really appreciate some guidance!

Best,

Aidan

The offsetting of the limits is specific to the voltage levels, so I don’t think that will be reasonable to mess with. You could right some functions to further calibrate with the values you’re getting. However, I’m unable to assist in writing that custom code.

Thank you!