Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    How to use the same sensor API with several sensors (BNO055)

    How to use the same sensor API with several sensors (BNO055)

    gcb
    Member

    Hi

    I'm trying to use the Bosch Sensortech API for the BNO055 sensor. The API can be found here. I would like to use two BNO055 sensors on the same I2C bus (each with different addresses) or in different I2C buses (in this case with the same address).

    1. After reading the API, I understood I can create a structure to store the device information:

    struct bno055_t myBNO;

    2. Then link my MCU I2C driver functions to the API communication function pointers:

    myBNO.bus_read = BNO055_I2C_bus_read();
    myBNO.bus_write = BNO055_I2C_bus_write();
    myBNO.delay_msec = delay;

    3. Configure the correct I2C address of my device:

    myBNO.dev_addr = BNO055_I2C_ADDR1;

    4. And finally do API initialization by passing the reference of my object with device information:

    bnO055_init(&myBNO);

    Inside of the API file (bno055.c) we can se a pointer of type bno055_t that will point to my myBNO device. And from now on, all API Calls are related to this device. So if I try to do the point 4) again but with the reference to my second sensor, lets say:

    bnO055_init(&myBNO_2);

    The API just lost the information of the first device and will work only for the second one.

    So if I have another BNO055 sensor with another I2C address how can I use this API?
    Or if I have another BNO55 sensor with the same address but in a different I2C bus how can I use this API?

    Creating multiple objects of type bno055_t is possible. Setting a different address and linking different I2C driver functions (depends on which I2C0 or I2C1 bus I am using) is also possible. But then when I initialize the API using bnO055_init(), I am only able to do this once with only one device's information.

    Any suggestion?

    5 REPLIES 5

    BSTRobin
    Community Moderator
    Community Moderator

    Hi gcb,

    The I2C device addresses of two BNO055 must be different. Whether the two BNO055 are on one I2C bus or different bus, you can refer to the following examples.

    struct bno055_t bno055-1;
    struct bno055_t bno05-2;


    s8 I2C_routine-1(void)
    {
    bno055.bus_write = BNO055_I2C_bus_write-1;
    bno055.bus_read = BNO055_I2C_bus_read-1;
    bno055.delay_msec = BNO055_delay_msek;
    bno055.dev_addr = BNO055_I2C_ADDR1;

    return BNO055_INIT_VALUE;
    }

    s8 I2C_routine-2(void)
    {
    bno055.bus_write = BNO055_I2C_bus_writ-2;
    bno055.bus_read = BNO055_I2C_bus_read-2;
    bno055.delay_msec = BNO055_delay_msek;
    bno055.dev_addr = BNO055_I2C_ADDR2;

    return BNO055_INIT_VALUE;
    }

    Also, the Bosch team should be careful when writing documentation on github. In the BNO055 repository there are many errors. Some { in the wrong place, the support.c file sometimes spoke in I2C, sometimes in SPI... it's quite confusing.

    BSTRobin
    Community Moderator
    Community Moderator

    Hi gcb,

    This is a reference code. You can modify it based on this code.

    Hi

    I understand it's just a reference code to use. But at least it should conform to what the datasheet indicates.

    The BNO055 datasheet indicates in Table 3-6 that the switching time from CONFIG MODE to another operating mode is 7ms and that the switching time from any operating mode to COFIGMODe is 19ms. However, in your API you have defined the following in the .h file:
                       #define BNO055_MODE_SWITCHING_DELAY 600
    And in the .c file when implementing the bno055_set_operation_mode() function say somewhere:
                      /* Config mode to other  operation mode switching  required delay of 600ms*/

    There is a lot of discrepancies between your API implementation and the sensor datasheet.

    Best regards

    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