Bosch Sensortec Community

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

    BHI160B BoschSensorHub library

    BHI160B BoschSensorHub library

    bgfas
    New Poster

    I am trying to bring up a board with a BHI160B. Is the library found at https://github.com/BoschSensortec/BoschSensorHub known to work for this sensor?

    The circuit involves a BHI160B with no attached secondary devices, should I be using the Bosch_PCB_7183_di03_BMI160-7183_di03.2.1.11696_170103.h firmware? The application only requires reading the accelerometer and gyroscope virtual sensors.

    26 REPLIES 26

    BSTRobin
    Community Moderator
    Community Moderator

    Hi bgfas,

    Could you give further feedback? Thanks.

    Hi,

    Apologies as I did not see the notification for your previous message.

    Here's the list of sensor ids for the "Bosch_PCB_7183_di03_BMI160_BMM150-7183_di03.2.1.11696_170103.h" firmware

    Supported Virtual Sensor Information:
    -wakeup-
    id=1
    id=2
    id=3
    id=4
    id=9
    id=10
    id=11
    id=14
    id=15
    id=16
    id=17
    id=18
    id=19
    id=20
    id=22
    id=23
    id=24
    id=25
    id=31
    -non-wakeup-
    id=1
    id=2
    id=3
    id=4
    id=9
    id=10
    id=11
    id=14
    id=15
    id=16
    id=17
    id=18
    id=19
    id=20
    id=22
    id=23
    id=24
    id=25
    id=31

    for the "Bosch_PCB_7183_di03_BMI160-7183_di03.2.1.11696_170103.h" firmware the ids are:

    Supported Virtual Sensor Information:
    -wakeup-
    id=1
    id=4
    id=9
    id=10
    id=15
    id=16
    id=17
    id=18
    id=19
    id=22
    id=23
    id=24
    id=25
    id=31
    -non-wakeup-
    id=1
    id=4
    id=9
    id=10
    id=15
    id=16
    id=17
    id=18
    id=19
    id=22
    id=23
    id=24
    id=25
    id=31

    Installing the callback returns with no error. Configuring the accelerometer returns with the -100 page select timeout error that I added because it reaches the end of pageSelect (https://github.com/BoschSensortec/BoschSensorHub/blob/master/src/bhy.cpp#L2098) without success (the device never appears ready and does not acknowledge the parameter change). The code in the BoschSensorHub repository leaves this behaviour undefined (the function terminates with no return value). If I change this otherwise underfined return to instead return success (0) the code continues but no accelerometer readings are ever returned.

    Thanks again for your help.

    BSTRobin
    Community Moderator
    Community Moderator

    Hi bgfas,

    Thank for your feedback.
    Do you mean you get -100 return value after call pageSelect()?
    You could modify the code like this and try it again.
    int8_t BHYSensor::pageSelect(bhyPage page, uint8_t parameter)
    {
    status = BHY_NONE;
    status = write(BHY_REG_PARAMETER_PAGE_SELECT_ADDR, page);
    if (status < 0)
    return status;

    status = write(BHY_REG_PARAMETER_REQUEST_ADDR, parameter);
    if (status < 0)
    return status;

    uint8_t ack = 0;
    for (uint8_t i = 0; i < 250; ++i)
    {
    status = read(BHY_REG_PARAMETER_ACKNOWLEDGE_ADDR, &ack);
    if (status < 0)
    return status;

    if (ack == parameter)
    return status = BHY_OK;
    else if (ack == 0x80)
    {
    delay(50);
    status = BHY_ERROR;
    }
    else
    delay(1); // device is not ready yet
    }

    return status;
    }

    Thanks for the reply.

    I tested the code and the device still does not supply accelerometer readings.

    The device is not responding with the appropriate ack (the parameter) after page selection. For the pageSelect code you linked this will result in 250 reads to check ack and if the last attempt returns an invalid ack but a successful read (status == BHY_OK) the function will erroneously return BHY_OK even though the ack was not successful. This is what's happening with the device I have here (all acks are 0x00).

    BSTRobin
    Community Moderator
    Community Moderator

    Hi bgfas,

    For further analysis, could you help capture I2C waveform between host and BHI160B with logic analyzer?

    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