Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 
    SOLVED

    Where is the example that works for getting the magnetometer data?

    Where is the example that works for getting the magnetometer data?

    tantingzhu
    New Poster

    I am working on BMX160 using I2C, I can get the data of Accel  but can't get any valid Magnetometer data. I found that almost all the examples using bmm150 to get this data. https://github.com/BoschSensortec/BMI160_driver/wiki/How-to-use-an-auxiliary-sensor-or-magnetometer-.... and https://community.bosch-sensortec.com/t5/MEMS-sensors-forum/BMX160-magnetometer-problem/td-p/7628/pa... , but I found some defines in bmm150_def.h are not the same as the datasheet of BMX160. For example : 

    #define BMM150_REG_CHIP_ID                        UINT8_C(0x40)
    it should be 0x00

    #define BMM150_CHIP_ID                            UINT8_C(0x32)
    it should be 0xD8

    I am worrying about it doesn't work. 
    6 REPLIES 6

    Minhwan
    Community Moderator
    Community Moderator

    Hi, 

     

    Please check my zip file. 

    You can check the bmx160_read_sensor_data example and modified bmi160 code. 

    Thanks, 

    Thank you for you help,Minhwan. I will transplant it to my platform and check it today.

    Hi Minhwan,
    I am not sure if the magetometer data I got  are correct or not.

    After I put the codes into my platform, it seems that the initialization is good, but I can't get the correct data from this codes(froom fifo), but I can read the datas from registers 0x04 to 0x17, and the data changed every time I read. the data of   accelerometer are correct for sure. But I am not sure if the data of the magetometer are correct or not. I have 2 BMX160 at the same place and they looks so different.   

    The data  of the first one looks strange.  I turned the BMX160 to different directions but the number of z always negative, from -170 to - 550, most of the time are -200 to -300.  and the number of y is always positive,  from 200 to 1700, most of the time 700-1200.the number of  x looks good, change a lot  when I turn it to different direction, from -159 to +1500.

    The data of another are different. z from -200 to + 100, y from -200 to +1500, x  from -200 to +1500.  

    here are the data at the same direction at the same time almost at the same place. ('point' and 'face'  are different faces of our product,they are 90 degree )
    point to south ,  face up:                     #1,   993,   1665, -501          #2,   849,  1145,   -245
    point to south ,  face down:               #1,  1001, 329,    -247          #2,   945,  505,     103
    point to north ,  face up                       #1,  249,   1697,   -463         #2,     89,   1433,  -203 
    point to north ,  face down                #1,  249,      289,     -291        #2,  113,   -135,   -45
    point up face south                              #1,  1433,  1449,    -389        #2,  1273, 1145,  -77
    point up face north                              #1,  1433,      625,    -379       #2,  1337,    193,   -39
    point down face south                        #1, -183,      1153,   -493       #2,   -335,  1001,  -177 
    point down face north                        #1,  -167,        593,    -323       #2,  -263,     329,  -15

    data change a little when put it to the same direction.

    Minhwan
    Community Moderator
    Community Moderator

    Hi tangtingzhu, 

     

    I'm gonna check it and back to you. 

    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