Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    BMI160 undeclared values error

    herez1
    Member

    BMI160 undeclared values error

    Hi,

    I use BMI160 with STM32F4. I have driver from Bosch Sensortec (https://github.com/BoschSensortec/BMI160_driver) but i cannot get true value from sensor. I want to get gyro and accel values for x, y and z. I initialize the sensor. You can see here:

    herez1_0-1648153167271.png

    Then, I want to use these values from bmi160_defs_h:

    herez1_2-1648153360115.png

    herez1_3-1648153466663.png

    But i get an error: 'x', 'y', 'z' undeclared, first use in this function. How can i fix it? 

    Please help.

    5 REPLIES 5
    FAE_CA1
    Community Moderator

    Re: BMI160 undeclared values error

    Hi,

    Thanks for your inquiry.

    After power on both BMI160 accel and gyro are in suspend mode. You need to write value of 0x11 to command register 0x7E to bring accel to normal mode and wait 5ms for the accel to be stabilized. Then you can write value of 0x15 to command register 0x7E to bring gyro to normal mode and then wait 55ms for the gyro to be stabilized. Then you can read those data registers to get the values from accel and gyro measurements.

    Please refer to the example code on the Github at https://github.com/BoschSensortec/BMI160_driver/blob/master/examples/read_sensor_data/read_sensor_da... for more information.

    Thanks.

    herez1
    Member

    Re: BMI160 undeclared values error

    Hi, 

    Thanks for your help. 

    Now, I am getting accel and gyro values but they are all 0. How can i fix it?

    Please help. Thanks.

    herez1_0-1648247095133.png

     

    FAE_CA1
    Community Moderator

    Re: BMI160 undeclared values error

    Hi,

    Your code is correct. But you need to initialize BMI160 first. Please see the attached two PDF files as an example. You can also refer to the example code that I showed you in github to get sensor data.

    Thanks.

    herez1
    Member

    Re: BMI160 undeclared values error

    Hi again,

    I am sorry about that but i couldn't again. I check your example code and read your PDF. I initialize them but i get an "undefined reference" error. For example "undefined reference to init_sensor_interface". You can see here my init functions:

    herez1_0-1648405334908.png

     And if "rslt == BMI160_OK", i read from my serial screen "BMI160 initialization success!" but if it is not, i read  "BMI160 initialization fail!". So my "BMI160_OK" is not true. Also my gyro and accel values are still 0. Because of initialization, i guess. So, what can i do? It is so important for me.

    Thanks.

    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