MPU6050 - Motorcycle roll angle

I’m new in the Community.

I try to build a simple object that I could put anywhere on my bike and that could return me roll angle on a screen.

I managed to connect the 2560 board, MPU6050 and I2C screen. Everything work. I have some data to show with example codes on arduino software.

In my case, I only need roll angle.

As the sensor would be place randomly (not on a flat surface), the calibration process will allow to transform MPU6050 position (relative) to the roll angle of the bike (absolute).

First, I need the sensor to know its relative position.

I think I can have half the solution thanks to g acceleration. Il will have a value for the 3 vectors (x, y, z) if my sensor is not flat positionned.
The other half would be done by rolling the bike from one side to other side in order to have the axis of the absolute roll.

Then I should get some "correction factors" to compute to gyro x, gyro, y and gyro z values given by the sensor to show my absolute roll.

Question : Do you think I’m doing right or does a better way already exist ?

Thanks.

This topic comes up quite often on the forum. To see what others have done, search for "arduino motorcycle roll angle", or "tilt angle" etc.

Basically you need to run the chip as a full IMU to get the orientation in space, then get Euler angles out.
You cannot get anything usable just from the accelerometer, you must fuse gyro and accelerometer data
like any IMU to get 3D orientation, then pick out the angle you want from the orientation. No different from
measuring roll for an aircraft.