How to calculate the tilt angle using the data from BMI160?

Dear All,

Great to know this community.

This is the first time to work with the Bosch sensor.

I'm trying to find out a way to get the tilted angle of BMI160.

If you have any source code or application notes for that, let me get it, please.

Thanks for your help in advance.

Best reply by agoransson

I think there are loads of examples for calculating the angle from accelerometer (gravity) values. Perhaps something like this will explain? http://www.hobbytronics.co.uk/accelerometer-info 

I haven't tried this code myself though.

 

To get the accelerometer values you can do something like this:

 u8 int_data[6] = {0, 0, 0, 0, 0, 0};
s16 acc_x, acc_y, acc_z;
bmi160_get_regs(0x12, &int_data, 6, dev);

acc_x = ((int_data[1] << 8 | int_data[0]));
acc_y = ((int_data[3] << 8 | int_data[2]));
acc_z = ((int_data[5] << 8 | int_data[4]));
 
Read the 6 registers (0x12 - 0x17) and combine them into 16 bit signed integers to get the accelerometer values to use for your calculations.
 
View original
2 replies
Resolved