I am using Bosch BMI160 sensor for measuring the acceleration and orientation and I am writing an Arduino script for that. In the datasheet the registers for these data are 0x0C - 0x17.
So to get i.e. the x axis of the acceleration in m/s², I multiply my value for acceleration_x with 9,81 and divide it by the sensitivity (for 2g in my case). But my problem is, for the x-axis of acceleration I have an LSB and a MSB (Register 0x12 and 0x13). My question is now, which one do I have to choose? Only reading the LSB? Or do I have to make calculations with both and if yes, how?
Solved! Go to Solution.
Pg02 of the datasheet says that BMI160 integrates a 16bit digital accel and a 16bit digital gyro
So, you have to read both registers (MSB and LSB) and combine them, something like this:
lsb = data_array[idx++]; msb = data_array[idx++]; msblsb = (int16_t)((msb << 😎 | lsb); accel->x = msblsb; /* Accel data in X axis */
Combining both registers you will get a 16bit number that represents LSBs. Then you just need to convert from LSB to m/s2 or degrees/s (depending by your sensor) following the datasheet
Hope this heps