wollewald / ADXL345_WE

Arduino Library for the ADXL345 accelerometer. I2C and SPI are implemented.
https://wolles-elektronikkiste.de/en/adxl345-the-universal-accelerometer-part-1
MIT License
40 stars 9 forks source link

calibrate #2

Closed tonyvr4 closed 2 years ago

tonyvr4 commented 3 years ago

How can I calibrate the ADXL345. It seems that the numbers do not want to settle to zero even if the module is taped to a desk

wollewald commented 3 years ago

I have only implemented a method to ensure to get a min/max of -1g/+1g for each axis. For this the min/max values for the axes are used (only gravity). The min/max raw values I obtained for one module for x,y,z were for example: -266/+285, -268/+278, -291/214. Ideally that should be symmetrical. I have made the asssumption that the zero point (when the sensor for the axis is at 0°) is in the middle: (min + max)/2. This may be true, but it could also be that the zero degrees is really where the sensor measures 0 and the slope is different from 0 to 90 and 0 to -90. What is really true I don't know. I have not fod this information.

I assume you would like to have 0g for x and y and 1g for z when the sensor is positioned flat. Of course I could set offsets for this starting position and in fact I did this for measuring (small) angles (see example sketch). But with this method you not necessarily get -/+1g for -/+90°C. I hope you can still follow my thoughts. At the end I did not find the one method which really ensures correct calibration in order to have the right starting values 0/0/1g and the right slope. That's why I have not implemented it.

wollewald commented 2 years ago

Since there was no further discussion I close this issue.