Accelerometer Orientation (LIS3DH)

Hi! Newbie here!
I'm trying to make a pocket level using an LIS3DH but I don't know how to "reset" all the axis to start reading from a certain orientation since my LIS3dh won't be mounted flat and will change often.
Ideally whenever the level starts it would start reading everything at 0 no matter the orientation.
I'm sure it's just math, but it's way over my head to begin to understand it.

Starting with the absolute basics I'm using the adafruit lib. I can easily get all the readings, and I understand they are acceleration forces. But how do I start them all from 0?

Initially I was thinking to take the very first reading and store it, then add or subtract the new readings from the originals based on if the new numbers are higher or lower than original (subjectively) but that only works in some instances which means that it wasn't a good solution.

I don't have specific code to share as I'm using the adafruit LIS3DH example.

Here's a reading from the sensor of it not flat

X: -11408 Y: -3152 Z: 10560 X: -6.87 Y: -1.87 Z: 6.27 m/s^2

And here's readings closer to a flat surface

X: -80 Y: 704 Z: 16176 X: -0.02 Y: 0.46 Z: 9.86 m/s^2

You can't reset the axes, the sensors axes are a mechanical fact about the sensor.

You can transform the readings to a different frame of reference using a DCM or
quarternion representing the change in orientation between sensor and the environment.

I'm an American, was that English? lol.

The accelerometer measures the acceleration due to gravity, as well as due to other forces.

To measure tilt away from an arbitrary starting orientation takes two steps: first measure the acceleration at the starting orientation, then in the second. Finally, calculate the angle between the two vectors to get the tilt.

Ooops, I misspelt quaternion, sorry for the confusion(!)

You'll need to understand some basic concepts about mechanics such as frames of
reference and rotation transformations to deal with 3D sensors like this. Quaternions
and DCMs are two mathematical objects for describing a 3D rotation. Various libraries
will be using one or both of these typically, as well as being able to convert to Euler
angles for external use.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.