Bosch Sensortec Community

    Showing results for 
    Search instead for 
    Did you mean: 

    BMM150 confusion about compass orientation

    BMM150 confusion about compass orientation

    New Poster

    I am using the BMM150 on a waveshare module ( under Python (code below).

    Data seem to be coming out ok, like:

    X:36.325 µT  Y:0.000  µT  Z:48.786 µT  Magnitude:60.825 µT Heading: 86.349 DEG

    The chip is oriented so that the X-direction (as printed on the PCB) is pointing due North.


    I do expect this to give a heading of 0 (zero) degrees, yet it is giving 86.3°, which I take as 90°.

    Do I use wrong code, or am I mistaken on my interpretation?

    Code used:

            import numpy as np
            import bmm150
            device = bmm150.BMM150()
            x, y, z   = device.read_mag_data()
            heading   = np.degrees(np.arctan2(x, y))     


    2 REPLIES 2

    Community Moderator
    Community Moderator


    Thanks for your inquiry.

    The BMM150 data you got is so called raw data in the unit of uT. You cannot directly use these raw data to calculate heading. You need to performance BMM150 calibration by moving your PCB randomly in 3D space slowly. Please refer to a video clip at for more information. You may also do a Google search on magnetometer calibration online where you can find a lot of articles, libraries and source codes that you can use in your project.

    After calibration you can test heading on a flat surface without any metal stuff nearby. If you want to get eCompass in 3D, then you also need an accelerometer to work together with BMM150 to get tilt compensated heading.

    One more note is that BMM150 has been discontinued. You can find PDN document in this community. Please switch to new magnetometer BMM350. You can purchase a BHI360 shuttle board through Digikey where BMM350 is installed. You can then get accurate heading directly from BHI360 because the sensor fusion algorithm running inside BHI360 has already taken care of BMM350 calibration and tilt compensation. Please see the attached PDF file for more information.


    Thank you. But I did the random moving in space well before I posted my question, and I don't want any more libraries, and I am using the chip flat on a horizontal question and I don't want 3D compensation, and my lib does have the temp compensation.

    And thanks for the marketing push for your new sensor, but for now I am using the BMM150.

    But you did not answer my only question: what should the heading readout b, when the chip is placed on a flat, horizontal surface, with the X-axis pointing north? Is it 0 degrees, or is it 90degrees, or anything else?