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,

    1.Yes. The BHI160B code is for Arduino;
    2. Yes, you could use this firmware for BHI160B without secondary devices.

    Thank you for the confirmation.I am however having issues getting the accelerometer readings to report reliably.

    I had to make some minor changes to get the basic.ino example to compile:

    1) LITTLE_ENDIAN redefined. This board uses a NRF52840 with a toolchain that already defines LITTLE_ENDIAN. I replaced LITTLE_ENDIAN (and BIG_ENDIAN) in the BoschSensorHub to BHY_LITTLE_ENDIAN (BHY_BIG_ENDIAN).

    2) BHYSensor::pageSelect missing return statement. If the device fails to return an error or ack (matching parameter) in the parameter acknowledge register within 250 milliseconds the function reaches an undefined return. I added a BHY_E_PAGE_SELECT_TIMEOUT error for this state.

    The changes can be found here: https://github.com/braingram/BoschSensorHub/commit/2c3cdd8dd3624a26cd80144f99156acddb23a301

    With these changes the basic.ino compiled and loaded with no issues. I modified orientation.ino to attempt to read the accelerometer (file found here: https://github.com/braingram/BoschSensorHub/blob/master/examples/accel/accel.ino).

    This code compiles and runs however I've encountered 2 different problems (with different boards). Some boards report:

    ```

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

    ```

    Others successfully read a few dozen accelerometer readings and then suddenly stops with no reported error.

    ```

    Serial working
    setup...
    Sensor found over I2C! Product ID: 0x83
    Uploading Firmware.
    Firmware booted
    Orientation callback installed
    Accelerometer (Non Wake-up) virtual sensor enabled
    All ok
    -3966.00,-2508.00,-7345.00,0
    -3951.00,-2516.00,-7332.00,0
    -3947.00,-2513.00,-7324.00,0
    -3955.00,-2514.00,-7319.00,0
    -3954.00,-2509.00,-7323.00,0
    -3959.00,-2493.00,-7328.00,0
    -3954.00,-2508.00,-7325.00,0
    -3958.00,-2514.00,-7330.00,0
    -3961.00,-2510.00,-7333.00,0
    -3961.00,-2500.00,-7313.00,0
    -3950.00,-2496.00,-7325.00,0
    -3942.00,-2505.00,-7328.00,0
    -3942.00,-2514.00,-7323.00,0
    -3951.00,-2501.00,-7319.00,0
    -3960.00,-2491.00,-7316.00,0
    -3957.00,-2503.00,-7328.00,0
    -3953.00,-2512.00,-7325.00,0
    -3953.00,-2515.00,-7330.00,0
    -3962.00,-2510.00,-7318.00,0
    -3959.00,-2506.00,-7322.00,0
    -3949.00,-2509.00,-7329.00,0
    -3952.00,-2504.00,-7322.00,0
    -3957.00,-2504.00,-7320.00,1
    -3959.00,-2504.00,-7312.00,1
    -3955.00,-2504.00,-7323.00,1
    -3953.00,-2505.00,-7323.00,1
    -3947.00,-2505.00,-7324.00,1
    -3962.00,-2518.00,-7324.00,1
    -3960.00,-2503.00,-7320.00,1
    -3956.00,-2506.00,-7322.00,1
    -3957.00,-2506.00,-7331.00,1
    -3952.00,-2504.00,-7337.00,1
    -3952.00,-2507.00,-7331.00,1
    -3959.00,-2500.00,-7325.00,1
    -3962.00,-2503.00,-7320.00,1
    -3953.00,-2510.00,-7325.00,1
    -3955.00,-2506.00,-7333.00,1

    ```

    I've attached the portion of the circuit with the BHI160B. VDD_nRF is 3.3 volts and the same supply that powers the NRF52840. There are a few other devices on the i2c bus (MMC5633 and MCP7940).

    Thanks again for your help and any advice is greatly appreciated.

    BSTRobin
    Community Moderator
    Community Moderator

    Hi bgfas,

    The firmware can be loaded successfully, indicating that the firmware and the chip are matched.

    Have you tested if there is only BHI160B on the I2C bus?

    Hi BSTRobin,

    Thanks for the reply. There are 2 other devices on the bus, a MMC5633 and MCP7940. I am able to communicate with both the BHI160B and MMC5633 and can reliably read the chip id registers with no errors after many thousands of reads (I have not yet tested the MCP7940). Is there an issue with sharing the i2c bus used for the BHI160B with other chips?

    I have done more testing with the board that fails to enable the virtual sensor with still no luck. Below is some output from the tests showing that the firmware upload apparently succeeds. However after attempting to enable the virtual sensor the chip status changes to 0x90. This appears incorect as the datasheet states that bits 7..5 should be fixed to 0.

     

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

     

    The code can be found here: https://github.com/braingram/BoschSensorHub/blob/master/examples/accel/accel.ino

    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