Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    BMM150 Z value not correct

    Established Member

    BMM150 Z value not correct

    Hi,
    I'm using a BMM150 as auxiliary sensor of a BMI270.
    The communication works correctly, but I get weird data for the Z axis.

    Debugging the sensor API I noticed that the `compensate_z` function always returns `BMM150_OVERFLOW_OUTPUT` because `dev->trim_data.dig_z2` is always ZERO.

    How is this possible?

    Thank you
    Walter

    12 REPLIES 12
    Community Moderator

    Re: BMM150 Z value not correct

    Would you be able to share any further details about your setup? For example any of the following could help: your schematic (unless you are using our official Shuttle Board(s)?), code snippets, timing information, logic trace, etc.

    Established Member

    Re: BMM150 Z value not correct

    The sensor is connected to BMI270 as auxiliar I2C device.

    This is my initialization code:

    int8_t BMM150_DEVICE_Init() {
    	systemStatus.bmm150_init_count++;
    
    	int8_t rslt = BMM150_OK;
    
    	// ----> BMM150 initialization over I2C (BMI270 aux)
    	bmm150_dev.dev_id = BMM150_DEFAULT_I2C_ADDRESS;
    	bmm150_dev.intf = BMM150_I2C_INTF;
    	bmm150_dev.read = bmm150_read;
    	bmm150_dev.write = bmm150_write;
    	bmm150_dev.delay_ms = bmm150_delay_ms;
    
    	rslt = bmm150_init(&bmm150_dev);
    	if(rslt!=BMM150_OK) {
    		goto exit;
    	}
    	// <---- BMM150 initialization over I2C (BMI270 aux)
    
    	// ----> Configuration
    	bmm150_dev.settings.preset_mode = BMM150_PRESETMODE_REGULAR;
    	rslt = bmm150_set_presetmode(&bmm150_dev);
    	if(rslt!=BMM150_OK) {
    		goto exit;
    	}
    
    	bmm150_dev.settings.pwr_mode = BMM150_NORMAL_MODE;
    	rslt = bmm150_set_op_mode(&bmm150_dev);
    	// <---- Configuration
    
    	exit:
    	if( rslt == BMM150_OK ) {
    		systemStatus.bmm150_initialized = 1;
    	} else {
    		systemStatus.bmm150_initialized = 0;
    	}
    	return rslt;
    }

     

    One of the weird thing that I noticed is that after putting a neodymium magnet near the sensor it started working like if there was something "blocked".

    Highlighted
    Community Moderator

    Re: BMM150 Z value not correct

    Assuming BMI270's auxiliary interface configuration, bmm150_read/write functions, timings/delays and data read-out are all correct, this short code snippet seems valid. Joining this other comment, BMM150 is actually quite robust against magnetization and magnetic shocks, therefore I would also make sure that the magnetic environment around the sensor is also relatively stable and clean.

    Established Member

    Re: BMM150 Z value not correct

    I would reiterate what was said in the linked comment linked above:  "What you are seeing is most likely the effect of magnetization of OTHER components around the PCBs, such as mounting screws, standoffs, batteries, metal case, etc."

    Moving a neodymium magnet near the hardware will likely magnetise such components even if the BMM150 itself is immune. It can also have the effect of undoing magnetisation to some extent (i.e. magnetising in the opposite direction) which could explain your 'fix'.

    Nearby magnetised components offset magnetometer measurements by a fixed amount. This effect if often referred as a hard-iron distortion and must be accounted for in calibration.  It is often necessary to provide the end user with a means of performing this calibration.  However, you should take care when designing your product that such distortions do not risk saturating measurements.

    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