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,

    There is no problem multiple save devices share same I2C bus.

    Orientation is also a example code of virtual sensor, could you run this official example and see if it works well?
    https://github.com/BoschSensortec/BoschSensorHub/blob/master/examples/orientation/orientation.ino

    Hello,

    Thanks again for your reply and the suggestion. Unfortunately this board does not have a BMM150 (only a BHI160b). When I attempt to run the firmware I get the following output:

    """

    Serial working
    Sensor found over I2C! Product ID: 0x83
    Uploading Firmware.
    Firmware booted
    Orientation callback installed
    Failed to enable virtual sensor (Orientation (Non Wake-up)). Loaded firmware may not support requested sensor id.

    """

    BSTRobin
    Community Moderator
    Community Moderator

    Hi bgfas,

    You could print supported sensor ID after calling getSensorInformation(), and see what sensor ID does current firmware support?

    Hi BSTRobin,

    I'm not sure which sensor_id you're referring to. I'm assuming it's not the constant defined here:

    https://github.com/BoschSensortec/BoschSensorHub/blob/master/src/bhy_defs.h#L162

    Would you help me understand what sensor_id you're looking for?

    I added code to print out for the orientation and accelerometer sensors (wakeup) bhySensorInforrmation after loading the firmware. The code snippet is here:

    """

    intrToggled = false; /* Clear interrupt status received during firmware upload */
    waitForBhyInterrupt(); /* Wait for meta events from boot up */
    Serial.println("Firmware booted");

    /* Install a metaevent callback handler and a timestamp callback handler here if required before the first run */
    bhi160.run(); /* The first run processes all boot events */

    bhySensorInformation information;

    bhi160.getSensorInformation(BHY_VS_ORIENTATION, true, &information);
    Serial.println("BHY_VS_ORIENTATION wakeup");
    Serial.print("type: "); Serial.println(information.type);
    Serial.print("driver_id: "); Serial.println(information.driver_id);
    Serial.print("driver_version: "); Serial.println(information.driver_version);
    Serial.print("power: "); Serial.println(information.power);
    Serial.print("max_range: "); Serial.println(information.max_range);
    Serial.print("resolution: "); Serial.println(information.resolution);
    Serial.print("fifo_reserved: "); Serial.println(information.fifo_reserved);
    Serial.print("fifo_max: "); Serial.println(information.fifo_max);
    Serial.print("event_size: "); Serial.println(information.event_size);
    Serial.print("min_rate: "); Serial.println(information.min_rate);

    bhi160.getSensorInformation(BHY_VS_ACCELEROMETER, true, &information);
    Serial.println("BHY_VS_ACCELEROMETER wakeup");
    Serial.print("type: "); Serial.println(information.type);
    Serial.print("driver_id: "); Serial.println(information.driver_id);
    Serial.print("driver_version: "); Serial.println(information.driver_version);
    Serial.print("power: "); Serial.println(information.power);
    Serial.print("max_range: "); Serial.println(information.max_range);
    Serial.print("resolution: "); Serial.println(information.resolution);
    Serial.print("fifo_reserved: "); Serial.println(information.fifo_reserved);
    Serial.print("fifo_max: "); Serial.println(information.fifo_max);
    Serial.print("event_size: "); Serial.println(information.event_size);

    """

    And output is as follows:

    """

    Serial working
    Sensor found over I2C! Product ID: 0x83
    Uploading Firmware.
    Firmware booted
    BHY_VS_ORIENTATION wakeup
    type: 35
    driver_id: 254
    driver_version: 1
    power: 0
    max_range: 1
    resolution: 16
    fifo_reserved: 0
    fifo_max: 1893
    event_size: 8
    min_rate: 1
    BHY_VS_ACCELEROMETER wakeup
    type: 33
    driver_id: 48
    driver_version: 1
    power: 1
    max_range: 4
    resolution: 16
    fifo_reserved: 0
    fifo_max: 1893
    event_size: 8
    min_rate: 1
    Orientation callback installed
    Failed to enable virtual sensor (Orientation (Non Wake-up)). Loaded firmware may not support requested sensor id.

    """

    BSTRobin
    Community Moderator
    Community Moderator

    Hi bgfas,

    For your firmware, you could refer the following code to print supported virtual sensor information.

    /* get virtual sensor information from sensor hub */
    PDEBUG("Supported Virtual Sensor Information:\n");
    for(i = 1; i < 32; i++)
    {
    bhi160.getSensorInformation(BHY_VS_ORIENTATION, true, &information);

    if(information.type == i)
    PDEBUG("id=%2d\n", i);
    }

    for(i = 1; i < 32; i++)
    {
    bhi160.getSensorInformation(BHY_VS_ORIENTATION, false, &information);

    if(information.type == i)
    PDEBUG("id=%2d\n", i);
    }
    PDEBUG("");

    The print information should be like this:

    Supported virtual sensor information.png

    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