Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 
    SOLVED

    BMI160 - Using LSB & MSB or just LSB?

    BMI160 - Using LSB & MSB or just LSB?

    MarcelBendi
    New Poster

    Hey,

    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?

     

    Thank you!

    3 REPLIES 3

    Nikosant03
    Long-established Member

    Hi,

    Pg02 of the datasheet says that BMI160 integrates a 16bit digital accel and a 16bit digital gyro

    Screenshot_6.pngthat:

    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

    Screenshot_7.pngScreenshot_8.png

     

    Hope this heps

    Nick

    Thank you! But i furhter question: What would the folowing line do?

    msblsb = (int16_t)((msb <<  | lsb);

     

    Nikosant03
    Long-established Member
    Hi,
    For some reason the "8" is not shown on my previous post. This is the correct:

    msblsb = (int16_t)(msb << 8 | lsb);

    Nick
    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist