# Placing an accelerometer on arbitrary position and define this as the new coordinate system

I'm working on a small home project and I'm looking to use an accelerometer for tilt sensing. I would like to be able to place it anywhere on the object. If I place it in a way that the coordinate system on the device is not aligned with the object I would like to rotate this to match it.

Do I need to calculate a rotation matrix between the coordinate system I give the object (lets say I would like to have Y axis of the device be Z) and the coordinate system of the accelerometer itself?

• Do you have any accelerometer module in mind? If so can you post the part number. I think your objective might be achievable via software. Commented Aug 21, 2020 at 12:20

Yes, as a matter of fact you have to rotate a vector(that is 3D acceleration) from the sensor frame to your fixed frame of choice. To do so you need the rotation matrix that is dependent on the 3 rotation angles(pan, tilt and yaw).

In order to calibrate the system you may physically rotate your object so that gravity is aligned with your fixed frame directions and then compute the rotation angles. You have 3 unknowns so 3 positions are needed.

Since the object you are attaching the accelerometer is movable (otherwise no point in tilt sensing), then you might worried about even small (under 2 deg) misalignements.

My suggestion is to define setup function for alignment and the correcting in the software. If you are only worried about tilt (even if it is in two directions), you will be able to find the cosine between the gravity acceleration and the plane that the accelerometer is attached.

So the idea is to perform this calibration at the start up of the device (power on) for 3 to 5 sec. During that time the sensor should not be moved (but even that is not significant).

The added bonus is you can also do it at specified intervals if some conditions are met, and verify that there has not been any drift to the sensor.

One thing you may want to be careful about with using an accelerometer for navigational / tracking coordinate systems in an enclosed space is accumulating error. There are other ways to do navigation / tracking in a closed space that will yield better repeatability and accuracy. If you quickly move the object back and forth, you'll likely find that the position it reads is no longer exactly the same.

https://electronics.stackexchange.com/questions/248362/what-are-the-technical-difficulties-of-making-an-accurate-digital-accelerometer