Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    BNO055 always reads zero on all sensors and fusions

    BNO055 always reads zero on all sensors and fusions

    Eirenliel
    Member

    Hello, I'm running BNO055 via I2C, basically using examples from the driver https://github.com/BoschSensortec/BNO055_driver, I can talk to the IC, and get those versions:

    chip id A0, softwared rev 311, accel id FB, mag id 32, gyro id F, bootloader rev 15

    I set it into power mode 0 (BNO055_POWER_MODE_NORMAL) and I tried all operation modes, but when I try reading sensor data or fusion data, I get all 0, my quaternion is 0,0,0,0 and each sensor also returns 0,0,0. Calibration status status first reads 0330 (3 for accel and gyro, 0 for sys and mag) in IMU mode, but then reads 0000 for all sensors.

    I tried two different chips, they give the same results. Looks like sensors themselves don't start by some reason, and I can't figure out why.

    9 REPLIES 9

    I experience the same issue but even when operation mode set to 0x8 I still get 0s. I do set power mode to Normal. I did notice difference that switching power mode can get sensor to spit out 0s but now even when I don't switch power mode I still get 0s. Here is my code example

    void bno055_init_test(BNO055_imuReadOutData_t* bmo055OutData)
    {
    /*********read raw accel data***********/
    bmo055OutData->accel_datax = BNO055_INIT_VALUE; // variable used to read the accel x data
    bmo055OutData->accel_datay = BNO055_INIT_VALUE; // variable used to read the accel y data
    bmo055OutData->accel_dataz = BNO055_INIT_VALUE; // variable used to read the accel z data
    //struct bno055_accel_t accel_xyz;

    /*********read raw mag data***********/
    bmo055OutData->mag_datax = BNO055_INIT_VALUE; // variable used to read the mag x data
    bmo055OutData->mag_datay = BNO055_INIT_VALUE; // variable used to read the mag y data
    bmo055OutData->mag_dataz = BNO055_INIT_VALUE; // variable used to read the mag z data
    //struct bno055_mag_t mag_xyz;

    /***********read raw gyro data***********/

    bmo055OutData->gyro_datax = BNO055_INIT_VALUE; // variable used to read the gyro x data
    bmo055OutData->gyro_datay = BNO055_INIT_VALUE; // variable used to read the gyro y data
    bmo055OutData->gyro_dataz = BNO055_INIT_VALUE; // variable used to read the gyro z data
    //struct bno055_gyro_t gyro_xyz;

    /*************read raw Euler data************/

    bmo055OutData->euler_data_h = BNO055_INIT_VALUE; // variable used to read the euler h data
    bmo055OutData->euler_data_r = BNO055_INIT_VALUE; // variable used to read the euler r data
    bmo055OutData->euler_data_p = BNO055_INIT_VALUE; // variable used to read the euler p data
    //struct bno055_euler_t euler_hrp; // structure used to read the euler hrp data

    /************read raw quaternion data**************/
    bmo055OutData->quaternion_data_w = BNO055_INIT_VALUE; // variable used to read the quaternion w data
    bmo055OutData->quaternion_data_x = BNO055_INIT_VALUE; // variable used to read the quaternion x data
    bmo055OutData->quaternion_data_y = BNO055_INIT_VALUE; // variable used to read the quaternion y data
    bmo055OutData->quaternion_data_z = BNO055_INIT_VALUE; // variable used to read the quaternion z data
    //struct bno055_quaternion_t quaternion_wxyz; // structure used to read the quaternion wxyz data

    /************read raw linear acceleration data***********/
    bmo055OutData->linear_accel_data_x = BNO055_INIT_VALUE; // variable used to read the linear accel x data
    bmo055OutData->linear_accel_data_y = BNO055_INIT_VALUE; // variable used to read the linear accel y data
    bmo055OutData->linear_accel_data_z = BNO055_INIT_VALUE; // variable used to read the linear accel z data
    //struct bno055_linear_accel_t linear_acce_xyz; // structure used to read the linear accel xyz data

    /*****************read raw gravity sensor data****************/
    bmo055OutData->gravity_data_x = BNO055_INIT_VALUE; // variable used to read the gravity x data
    bmo055OutData->gravity_data_y = BNO055_INIT_VALUE; // variable used to read the gravity y data
    bmo055OutData->gravity_data_z = BNO055_INIT_VALUE; // variable used to read the gravity z data
    //struct bno055_gravity_t gravity_xyz; /* structure used to read the gravity xyz data
    u8 power_mode = BNO055_INIT_VALUE;

    /*Start initialization*/
    I2C_routine_BNO055();

    comres = bno055_init(&bno055); //checks ID versions
    power_mode = BNO055_POWER_MODE_NORMAL;
    comres += bno055_set_power_mode(power_mode);
    comres = bno055_set_operation_mode(BNO055_OPERATION_MODE_IMUPLUS); //BNO055_OPERATION_MODE_CONFIG
    //HAL_Delay(650);
    /*----------------------------------------*/


    success = bno055_read_register(BNO055_SYS_STAT_ADDR, &err_bmo055_buf[1], BNO055_GEN_READ_WRITE_LENGTH);

    if ((err_bmo055_buf[1]==0x01) || (err_bmo055_buf[0]!=0x0)){
    success = bno055_read_register(BNO055_SYS_ERR_ADDR, &err_bmo055_buf[0], BNO055_GEN_READ_WRITE_LENGTH);
    while (err_bmo055_buf[0]!=0x00){
    /*Software system reset */
    success = bno055_read_register(BNO055_SYS_TRIGGER_ADDR, &bno055_sys_trig, BNO055_GEN_READ_WRITE_LENGTH);
    write_buf = (bno055_sys_trig | BNO055_SYS_RST_MSK);
    bno055_set_operation_mode(BNO055_OPERATION_MODE_CONFIG);//not sure if I need this but setting it to write to the register
    success = bno055_write_register(BNO055_SYS_TRIGGER_ADDR,
    &write_buf, BNO055_GEN_READ_WRITE_LENGTH);
    /*------------------------------------------------------*/
    HAL_Delay(650); //just in case we need a little time to reset
    I2C_routine_BNO055(); //assign functions
    comres = bno055_init(&bno055); //checks ID versions

    comres += bno055_set_power_mode(BNO055_POWER_MODE_NORMAL); //set power mode
    bno055_set_operation_mode(BNO055_OPERATION_MODE_AMG);//set operation mode
    success = bno055_read_register(BNO055_SYS_STAT_ADDR, &err_bmo055_buf[1], BNO055_GEN_READ_WRITE_LENGTH);
    success = bno055_read_register(BNO055_SYS_ERR_ADDR, &err_bmo055_buf[0], BNO055_GEN_READ_WRITE_LENGTH);
    count = count + 1;
    }
    }
    //set to use external oscillator
    bno055_set_operation_mode(BNO055_OPERATION_MODE_CONFIG);
    success = bno055_read_register(BNO055_SYS_TRIGGER_ADDR, &bno055_sys_trig, BNO055_GEN_READ_WRITE_LENGTH);
    write_buf = (bno055_sys_trig | BNO055_CLK_SRC_MSK); //0x80;
    success = bno055_write_register(BNO055_SYS_TRIGGER_ADDR, &write_buf, BNO055_GEN_READ_WRITE_LENGTH);
    bno055_set_operation_mode(BNO055_OPERATION_MODE_AMG);

    success = bno055_read_register(BNO055_SELFTEST_RESULT_ADDR, &err_bmo055_buf[4], BNO055_GEN_READ_WRITE_LENGTH);
    if (err_bmo055_buf[4]!=0xf){
    success = bno055_read_register(BNO055_SYS_TRIGGER_ADDR, &bno055_sys_trig, BNO055_GEN_READ_WRITE_LENGTH);
    write_buf = (bno055_sys_trig | BNO055_SELFTEST_MSK); //0x01;
    //Do self-test
    success = bno055_write_register(BNO055_SYS_TRIGGER_ADDR, &write_buf, BNO055_GEN_READ_WRITE_LENGTH);
    }

    success = bno055_read_register(BNO055_SELFTEST_RESULT_ADDR, &err_bmo055_buf[4], BNO055_GEN_READ_WRITE_LENGTH);
    success = bno055_read_register(BNO055_SYS_CLK_STAT_ADDR, &err_bmo055_buf[2], BNO055_GEN_READ_WRITE_LENGTH);
    success = bno055_read_register(BNO055_INTR_STAT_ADDR, &err_bmo055_buf[3], BNO055_GEN_READ_WRITE_LENGTH);

    success = bno055_read_register(BNO055_CALIB_STAT_ADDR, &err_bmo055_buf[5], BNO055_GEN_READ_WRITE_LENGTH);

    /*---------------------------------------*/
    }
    BNO055_RETURN_FUNCTION_TYPE bno055_check_cal(bno055_calib* calib_results_struct){

    success = bno055_get_accel_calib_stat(calib_results_struct->accel_calib_status);
    success = bno055_get_gyro_calib_stat(calib_results_struct->gyro_calib_status);
    success = bno055_get_sys_calib_stat(calib_results_struct->sys_calib_status);
    success = bno055_get_mag_calib_stat(calib_results_struct->mag_calib_status);
    }
    /* This API is an example for reading sensor data
    * \param: Structure where data will be stored
    * \return: None
    */
    void bno055_data_readout_template(BNO055_imuReadOutData_t* bmo055OutData)
    {

    /* variable used to set the power mode of the sensor*/
    u8 power_mode = BNO055_INIT_VALUE;
    /* For initializing the BNO sensor it is required to the operation mode
    * of the sensor as NORMAL
    * Normal mode can set from the register
    * Page - page0
    * register - 0x3E
    * bit positions - 0 and 1*/
    //power_mode = BNO055_POWER_MODE_NORMAL;

    /* set the power mode as NORMAL*/
    //comres += bno055_set_power_mode(power_mode);
    /* For reading sensor raw data it is required to set the
    * operation modes of the sensor
    * operation mode can set from the register
    * page - page0
    * register - 0x3D
    * bit - 0 to 3
    * for sensor data read following operation mode have to set
    * SENSOR MODE
    * 0x01 - BNO055_OPERATION_MODE_ACCONLY
    * 0x02 - BNO055_OPERATION_MODE_MAGONLY
    * 0x03 - BNO055_OPERATION_MODE_GYRONLY
    * 0x04 - BNO055_OPERATION_MODE_ACCMAG
    * 0x05 - BNO055_OPERATION_MODE_ACCGYRO
    * 0x06 - BNO055_OPERATION_MODE_MAGGYRO
    * 0x07 - BNO055_OPERATION_MODE_AMG
    * based on the user need configure the operation mode*/
    comres += bno055_set_operation_mode(BNO055_OPERATION_MODE_IMUPLUS); //BNO055_OPERATION_MODE_AMG

    /************************* START READ RAW SENSOR DATA****************/
    /* Raw accel X, Y and Z data can read from the register
    * page - page 0
    * register - 0x08 to 0x0D*/
    comres += bno055_read_accel_x(&bmo055OutData->accel_datax);
    comres += bno055_read_accel_y(&bmo055OutData->accel_datay);
    comres += bno055_read_accel_z(&bmo055OutData->accel_dataz);
    comres += bno055_read_accel_xyz(&bmo055OutData->accel_xyz);

    /* Raw mag X, Y and Z data can read from the register
    * page - page 0
    * register - 0x0E to 0x13*/
    comres += bno055_read_mag_x(&bmo055OutData->mag_datax);
    comres += bno055_read_mag_y(&bmo055OutData->mag_datay);
    comres += bno055_read_mag_z(&bmo055OutData->mag_dataz);
    comres += bno055_read_mag_xyz(&bmo055OutData->mag_xyz);

    /* Raw gyro X, Y and Z data can read from the register
    * page - page 0
    * register - 0x14 to 0x19*/
    comres += bno055_read_gyro_x(&bmo055OutData->gyro_datax);
    comres += bno055_read_gyro_y(&bmo055OutData->gyro_datay);
    comres += bno055_read_gyro_z(&bmo055OutData->gyro_dataz);
    comres += bno055_read_gyro_xyz(&bmo055OutData->gyro_xyz);

    /************************* END READ RAW SENSOR DATA****************/

    /************************* START READ RAW FUSION DATA ********
    * For reading fusion data it is required to set the
    * operation modes of the sensor
    * operation mode can set from the register
    * page - page0
    * register - 0x3D
    * bit - 0 to 3
    * for sensor data read following operation mode have to set
    * FUSION MODE
    * 0x08 - BNO055_OPERATION_MODE_IMUPLUS
    * 0x09 - BNO055_OPERATION_MODE_COMPASS
    * 0x0A - BNO055_OPERATION_MODE_M4G
    * 0x0B - BNO055_OPERATION_MODE_NDOF_FMC_OFF
    * 0x0C - BNO055_OPERATION_MODE_NDOF
    * based on the user need configure the operation mode*/
    // comres += bno055_set_operation_mode(BNO055_OPERATION_MODE_NDOF);

    /* Raw Euler H, R and P data can read from the register
    * page - page 0
    * register - 0x1A to 0x1E */
    comres += bno055_read_euler_h(&bmo055OutData->euler_data_h);
    comres += bno055_read_euler_r(&bmo055OutData->euler_data_r);
    comres += bno055_read_euler_p(&bmo055OutData->euler_data_p);
    comres += bno055_read_euler_hrp(&bmo055OutData->euler_hrp);

    /* Raw Quaternion W, X, Y and Z data can read from the register
    * page - page 0
    * register - 0x20 to 0x27 */
    comres += bno055_read_quaternion_w(&bmo055OutData->quaternion_data_w);
    comres += bno055_read_quaternion_x(&bmo055OutData->quaternion_data_x);
    comres += bno055_read_quaternion_y(&bmo055OutData->quaternion_data_y);
    comres += bno055_read_quaternion_z(&bmo055OutData->quaternion_data_z);
    comres += bno055_read_quaternion_wxyz(&bmo055OutData->quaternion_wxyz);

    /* Raw Linear accel X, Y and Z data can read from the register
    * page - page 0
    * register - 0x28 to 0x2D */
    comres += bno055_read_linear_accel_x(&bmo055OutData->linear_accel_data_x);
    comres += bno055_read_linear_accel_y(&bmo055OutData->linear_accel_data_y);
    comres += bno055_read_linear_accel_z(&bmo055OutData->linear_accel_data_z);
    comres += bno055_read_linear_accel_xyz(&bmo055OutData->linear_acce_xyz);

    /* Raw Gravity sensor X, Y and Z data can read from the register
    * page - page 0
    * register - 0x2E to 0x33 */
    comres += bno055_read_gravity_x(&bmo055OutData->gravity_data_x);
    comres += bno055_read_gravity_y(&bmo055OutData->gravity_data_y);
    comres += bno055_read_gravity_z(&bmo055OutData->gravity_data_z);
    comres += bno055_read_gravity_xyz(&bmo055OutData->gravity_xyz);

    /************************* END READ RAW FUSION DATA ************/

    /*-----------------------------------------------------------------------*
    ************************* START DE-INITIALIZATION ***********************
    *-------------------------------------------------------------------------*/

    /* For de - initializing the BNO sensor it is required
    * to the operation mode of the sensor as SUSPEND
    * Suspend mode can set from the register
    * Page - page0
    * register - 0x3E
    * bit positions - 0 and 1*/
    //power_mode = BNO055_POWER_MODE_SUSPEND;

    /* set the power mode as SUSPEND*/
    //comres += bno055_set_power_mode(power_mode);

    /*---------------------------------------------------------------------*
    ************************* END DE-INITIALIZATION **********************
    *---------------------------------------------------------------------*/
    //return comres;
    bmo055OutData->comres = comres;
    }

    I fixed the issue by using Adafruit's library: https://github.com/adafruit/Adafruit_BNO055 No ide why Bosch's driver didn't work for me, code looked fine to me, maybe some problems during compilation or similar.

    Thank you Eirenliel! I am wondering which compiler do you use and which family microcontroller? If that's compiler or micro issue it must be specific to certain family. Have new library resolved issue with SYS_STATUS reading 0x01 (error)? For me, this error doesn't go away even when I reset IMU.

    I'm not sure which compiler it uses, but I am using platformIO in vscode. My MCU is ESP8266 (ESP-12). Yes different library resolved all issues, I didn't investigate why exactly, but it's worth a shot, since it shouldn't be hard to swap.

    BSTRobin
    Community Moderator
    Community Moderator

    Hello all,

    https://github.com/adafruit/Adafruit_BNO055 is software provided by a third party, using C++.

    https://github.com/BoschSensortec/BNO055_driver is software provided by Bosch sensortec, using C. It is source code, no library, and could be migrated to different host MCU  platform.

     

    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