BMM150 Class
- ID: bmm150
- Name: 3-axis Geomagnetic Sensor
- Other Names: bmm050
- Category: compass
- Manufacturer: bosch
- Connection: i2c spi gpio
- Link: https://www.bosch-sensortec.com/bst/products/all_products/bmm150
The BMM150 is a standalone geomagnetic sensor for consumer market applications. It allows measurements of the magnetic field in three perpendicular axes. Based on Bosch's proprietary FlipCore technology, performance and features of BMM150 are carefully tuned and perfectly match the demanding requirements of all 3-axis mobile applications such as electronic compass, navigation or augmented reality.
An evaluation circuitry (ASIC) converts the output of the geomagnetic sensor to digital results which can be read out over the industry standard digital interfaces (SPI and I2C).
Not all functionality of this chip has been implemented in this driver, however all the pieces are present to add any desired functionality. This driver supports both I2C (default) and SPI operation.
This device requires 3.3v operation.
Item Index
Methods
- BMM150
- update
- getChipID
- getMagnetometer
- getMagnetometer
- init
- setPresetMode
- reset
- setOutputDataRate
- setPowerBit
- setOpmode
- getOpmode
- getInterruptEnable
- setInterruptEnable
- getInterruptConfig
- setInterruptConfig
- getInterruptStatus
- setRepetitionsXY
- setRepetitionsZ
- installISR
- uninstallISR
- readReg
- readRegs
- writeReg
Methods
BMM150
-
bus
-
addr
-
cs
BMM150 constructor.
This device can support both I2C and SPI. For SPI, set the addr to -1, and specify a positive integer representing the Chip Select (CS) pin for the cs argument. If you are using a hardware CS pin (like edison with arduino breakout), then you can connect the proper pin to the hardware CS pin on your MCU and supply -1 for cs. The default operating mode is I2C.
Parameters:
-
bus
NumberI2C or SPI bus to use.
-
addr
NumberThe address for this device. -1 for SPI.
-
cs
NumberThe gpio pin to use for the SPI Chip Select. -1 for I2C or for SPI with a hardware controlled pin.
Returns:
update
()
Update the internal stored values from sensor data.
getChipID
()
Number
Return the chip ID.
Returns:
The chip ID.
getMagnetometer
-
x
-
y
-
z
Return magnetometer data in micro-Teslas (uT). update() must have been called prior to calling this method.
Parameters:
-
x
Float *Pointer to a floating point value that will have the current x component placed into it.
-
y
Float *Pointer to a floating point value that will have the current y component placed into it.
-
z
Float *Pointer to a floating point value that will have the current z component placed into it.
getMagnetometer
()
Std::vector float
Return magnetometer data in micro-Teslas (uT) in the form of a floating point vector. update() must have been called prior to calling this method.
Returns:
A floating point vector containing x, y, and z in that order.
init
-
usage
Initialize the device and start operation. This function is called from the constructor so will not typically need to be called by a user unless the device is reset. This method will call setPresetMode() with the passed parameter.
Parameters:
-
usage
BMM150_USAGE_PRESETS_TOne of the BMM150_USAGE_PRESETS_T values. The default is BMM150_USAGE_HIGH_ACCURACY.
setPresetMode
-
usage
Set one of the Bosch recommended preset modes. These modes configure the sensor for varying use cases.
Parameters:
-
usage
BMM150_USAGE_PRESETS_TOne of the BMM150_USAGE_PRESETS_T values. The default is BMM150_USAGE_HIGH_ACCURACY.
reset
()
Perform a device soft-reset. The device will be placed in SUSPEND mode afterward with all configured setting lost, so some re-initialization will be required to get data from the sensor. Calling init() will get everything running again.
setOutputDataRate
-
odr
Set the magnetometer Output Data Rate. See the datasheet for details.
Parameters:
-
odr
BMM150_DATA_RATE_TOne of the BMM150_DATA_RATE_T values.
setPowerBit
-
power
Set or clear the Power bit. When the power bit is cleared, the device enters a deep suspend mode where only the REG_POWER_CTRL register can be accessed. This bit needs to be enabled for the device to operate. See the datasheet for details. The constructor enables this by default. After a deep suspend mode has been entered, all configured data is lost and the device must be reconfigured (as via init() ).
Parameters:
-
power
Booleantrue to enable the bit, false otherwise.
setOpmode
-
opmode
Set the operating mode of the device. See the datasheet for details.
Parameters:
-
opmode
BMM150_OPERATION_MODE_TOne of the BMM150_OPERATION_MODE_T values.
getOpmode
()
BMM150_OPERATION_MODE_T
Get the current operating mode of the device. See the datasheet for details. The power bit must be one for this method to succeed.
Returns:
One of the BMM150_OPERATION_MODE_T values.
getInterruptEnable
()
Number
Return the Interrupt Enables register. This register allows you to enable various interrupt conditions. See the datasheet for details.
Returns:
A bitmask of BMM150_INT_EN_BITS_T bits.
setInterruptEnable
-
bits
Set the Interrupt Enables register. See the datasheet for details.
Parameters:
-
bits
NumberA bitmask of BMM150_INT_EN_BITS_T bits.
getInterruptConfig
()
Number
Return the Interrupt Config register. This register allows determining the electrical characteristics of the 2 interrupt pins (open-drain/push-pull and level/edge triggering) as well as other options. See the datasheet for details.
Returns:
A bitmask of BMM150_INT_CONFIG_BITS_T bits.
setInterruptConfig
-
bits
Set the Interrupt Config register. This register allows determining the electrical characteristics of the 2 interrupt pins (open-drain/push-pull and level/edge triggering). See the datasheet for details.
Parameters:
-
bits
NumberA bitmask of BMM150_INT_CONFIG_BITS_T bits.
getInterruptStatus
()
Number
Return the interrupt status register. This register indicates which interrupts have been triggered. See the datasheet for details.
Returns:
a bitmask of BMM150_INT_STATUS_BITS_T bits.
setRepetitionsXY
-
reps
Set the repetition counter for the X and Y axes. This allows the device to average a number of measurements for a more stable output. See the datasheet for details.
Parameters:
-
reps
NumberA coefficient for specifying the number of repititions to perform. (1 + 2(reps))
setRepetitionsZ
-
reps
Set the repetition counter for the Z axis. This allows the device to average a number of measurements for a more stable output. See the datasheet for details.
Parameters:
-
reps
NumberA coefficient for specifying the number of repititions to perform. (1 + (reps))
installISR
-
intr
-
gpio
-
level
-
isr
-
arg
Install an interrupt handler.
Parameters:
-
intr
BMM150_INTERRUPT_PINS_TOne of the BMM150_INTERRUPT_PINS_T values specifying which interrupt pin you are installing.
-
gpio
NumberGPIO pin to use as interrupt pin.
-
level
Mraa::EdgeThe interrupt trigger level (one of mraa::Edge values). Make sure that you have configured the interrupt pin properly for whatever level you choose.
-
isr
FunctionThe interrupt handler, accepting a void * argument.
-
arg
Void *The argument to pass the the interrupt handler.
uninstallISR
-
intr
Uninstall a previously installed interrupt handler.
Parameters:
-
intr
BMM150_INTERRUPT_PINS_TOne of the BMM150_INTERRUPT_PINS_T values specifying which interrupt pin you are removing.
readReg
-
reg
Read a register.
Parameters:
-
reg
NumberThe register to read.
Returns:
The value of the register.
readRegs
-
reg
-
buffer
-
len
Read contiguous registers into a buffer.
Parameters:
-
reg
Numberundefined
-
buffer
Uint8_t *The buffer to store the results.
-
len
NumberThe number of registers to read.
Returns:
The number of bytes read.
writeReg
-
reg
-
val
Write to a register.
Parameters:
-
reg
NumberThe register to write to.
-
val
NumberThe value to write.