Gravity: BMM350 Triple Axis Magnetometer Wiki - DFRobot

Gravity BMM350

1.Introduction

The BMM350 3-axis digital geomagnetic sensor measures magnetic field strength in three spatial axes and features low power consumption (200uA), low noise (190nT rms@xy axis 450nT rms@z axis), high range (±2000μT), and high sampling rate (400~25/16Hz, selectable).

It utilizes TMR (Tunneling Magneto Resistance) technology and has a unique field impact recovery function. This feature makes the device highly robust to external magnetic fields, thus always ensuring high accuracy under the impact of surrounding magnetic fields.

It can be used for indoor and outdoor navigation and positioning, electronic compass, and AR/VR device application development.

2.Features

Sample code1-(getAllState.ino)

Sample code 2(getGeomagneticData.ino)

Sample Code 3 (thresholdInterrupt.ino)

8. API list

     /**
      * @fn softReset
      * @brief Software reset, reset to suspend mode after software reset.
      */
     void softReset(void);

     /**
      * @fn setOperationMode
      * @brief Setting the sensor's execution mode
      * @param opMode mode
      * @n BMM350_SUSPEND_MODE       Suspend Mode:Suspend mode is the default power mode of the BMM350 after the chip is powered up, the current consumption is minimized in suspend mode, so this mode is suitable for the period when no data conversion is required (all register reads and writes are possible)
      * @n BMM350_NORMAL_MODE        Normal mode: Acquisition of geomagnetic data
      * @n BMM350_FORCED_MODE        Forced mode: single measurement, sensor returns to pause mode when measurement is complete
      * @n BMM350_FORCED_MODE_FAST   ODR up to 200Hz only when using FM_FAST
      */
     void setOperationMode(uint8_t opMode);

     /**
      * @fn getOperationMode
      * @brief Get the sensor's execution mode
      * @return String is the execution mode of the sensor
      */
     String getOperationMode(void);

     /**
      * @fn setPresetMode
      * @brief Setting the preset mode makes it easier for the user to configure the sensor to acquire geomagnetic data (the default acquisition rate is 12.5 Hz).
      * @param presetMode
      * @n BMM350_PRESETMODE_LOWPOWER       Low power mode, get a small amount of data, take the mean.
      * @n BMM350_PRESETMODE_REGULAR        Normal mode, get medium data, take the mean.
      * @n BMM350_PRESETMODE_ENHANCED       Enhanced mode, get a lot of data, take the mean.
      * @n BMM350_PRESETMODE_HIGHACCURACY   High-precision mode, obtaining a large amount of data Taking the average value
      */
     void setPresetMode(uint8_t presetMode, uint8_t rate = BMM350_DATA_RATE_12_5HZ);

     /**
      * @fn setRate
      * @brief Set the rate of acquiring geomagnetic data, the larger the rate, the faster the acquisition (without the delay function).
      * @param rate
      * @n BMM350_DATA_RATE_1_5625HZ
      * @n BMM350_DATA_RATE_3_125HZ
      * @n BMM350_DATA_RATE_6_25HZ
      * @n BMM350_DATA_RATE_12_5HZ  (default speed)
      * @n BMM350_DATA_RATE_25HZ
      * @n BMM350_DATA_RATE_50HZ
      * @n BMM350_DATA_RATE_100HZ
      * @n BMM350_DATA_RATE_200HZ
      * @n BMM350_DATA_RATE_400HZ
      */
     void setRate(uint8_t rate);

     /**
      * @fn getRate
      * @brief Get the configured data rate.Unit: HZ
      * @return rate
      */
     uint8_t getRate(void);

     /**
      * @fn selfTest
      * @brief Sensor self-test, return value indicates self-test result
      * @param testMode:
      * @n     eBMM350_SELF_TEST_NORMAL               Routine self-test, check x-axis, y-axis, z-axis for on or short circuit
      * @return result The returned string is the result of the self-test
      */
     String selfTest(eBMM350_SELFTEST testMode = eBMM350_SELF_TEST_NORMAL);

     /**
      * @fn setMeasurementXYZ
      * @brief Enable x, y and z-axis measurement, the default setting is enable, the geomagnetic data of xyz-axis is not accurate after disable.
      * @param en_x
      * @n   BMM350_X_EN        Enable x-axis measurement
      * @n   BMM350_X_DIS       Disable x-axis measurement
      * @param en_y
      * @n   BMM350_Y_EN        Enable y-axis measurement
      * @n   BMM350_Y_DIS       Disable y-axis measurement
      * @param en_z
      * @n   BMM350_Z_EN        Enable z-axis measurement
      * @n   BMM350_Z_DIS       Disable x-axis measurement
      */
     void setMeasurementXYZ(enum bmm350_x_axis_en_dis en_x = BMM350_X_EN, enum bmm350_y_axis_en_dis en_y = BMM350_Y_EN, enum bmm350_z_axis_en_dis en_z = BMM350_Z_EN);

     /**
      * @fn getMeasurementStateXYZ
      * @brief Get the state of the x, y, and z axes
      * @return result Returns the string as state
      */
     String getMeasurementStateXYZ(void);

     /**
      * @fn getGeomagneticData
      * @brief Obtain geomagnetic data in the x, y, and z axes.
      * @return Structures of geomagnetic data. Unit: uT
      */
     sBmm350MagData_t getGeomagneticData(void);

     /**
      * @fn getCompassDegree
      * @brief Getting Compass Directions
      * @return compass angle (0° - 360°)
      * @n      0° = North, 90° = East, 180° = South, 270° = West.
      */
     float getCompassDegree(void);

     /**
      * @fn setDataReadyPin
      * @brief Enable or disable the data ready interrupt pin
      * @n Data coming to DRDY pin after enable.
      * @n Data won't coming to DRDY pin after disable.
      * @n high polarity:High level is the active level, the default is low level, the level becomes high when the interrupt is triggered.
      * @n low polarity:Low level is the active level, default is high, the level changes to low when the interrupt is triggered.
      * @param modes
      * @n     BMM350_ENABLE_INTERRUPT        Enable DRDY
      * @n     BMM350_DISABLE_INTERRUPT       Disable DRDY
      * @param polarity
      * @n     BMM350_ACTIVE_HIGH      high polarity
      * @n     BMM350_ACTIVE_LOW       low polarity
      */
     void setDataReadyPin(uint8_t modes, uint8_t polarity=POLARITY_HIGH);

     /**
      * @fn getDataReadyState
      * @brief Get the status of data readiness and use it to determine whether the data is ready or not.
      * @return status
      * @n true  The data is ready.
      * @n false The data is not ready.
      */
     bool getDataReadyState(void);

     /**
      * @fn setThresholdInterrupt(uint8_t modes, int8_t threshold, uint8_t polarity)
      * @brief Threshold interrupt, triggered when the geomagnetic value of a channel is above/below the threshold.
      * @n     High polarity: high level is active level, default is low level, level becomes high when interrupt is triggered.
      * @n     Low polarity: low level is active level, default is high level, the level changes to low when interrupt is triggered.
      * @param modes
      * @n     LOW_THRESHOLD_INTERRUPT       Low Threshold Interrupt Mode
      * @n     HIGH_THRESHOLD_INTERRUPT      High Threshold Interrupt Mode
      * @param  threshold
      * @n     Threshold, the default expansion is 16 times, e.g., if the threshold 1 is passed in the low threshold mode, the actual geomagnetic data lower than 16 will trigger an interrupt.
      * @param polarity
      * @n     POLARITY_HIGH      high polarity
      * @n     POLARITY_LOW       low polarity
      */
     void setThresholdInterrupt(uint8_t modes, int8_t threshold, enum bmm350_intr_polarity polarity);

     /**
      * @fn getThresholdData
      * @brief Get the data where a threshold interrupt occurred
      * @return Returns the structure that holds the geomagnetic data, which holds the three-axis data and the interrupt status.
      * @n No interrupt is triggered when the xyz-axis data is NO_DATA.
      * @n Mag_x, mag_y, mag_z Stores geomagnetic data.
      * @n Interrupt_x, interrupt_y, interrupt_z Stores axis interrupt status.
      */
     sBmm350ThresholdData_t getThresholdData(void);

9. FAQ

Q1:Why is it that sometimes the data range acquired exceeds the range?

A1:There is a limit to the measurement range of the BMM350, i.e. the sum of the absolute values for each axis should be less than this value. That is, SQRT(Hx^2 + Hy^2 + Hz^2) = 2000uT

​ You can refer to chapter 5.3 of the BMM350 datasheet below.

10. More Document