Component guide · Intermediate · 4 min read
BMM150 and BMM350 Magnetometers

Compass Wiring and Code
By Geekobot Learning Team · Updated 29 Oct 2026
On this page
The Bosch BMM150 and newer BMM350 are 3-axis magnetometers that measure the Earth's magnetic field to make a digital compass. They talk over I2C (the BMM350 also I3C) and pair well with a 6-axis IMU such as the BMI323 for full 9-axis orientation. Calibration for nearby metal and magnets is essential, and tilt compensation is needed for a heading when the board is not flat.
Key specs at a glance
- Range
- ±1300 µT (X, Y), ±2500 µT (Z) for BMM150; ±2000 µT for BMM350
- Resolution
- About 0.3 µT (BMM150), 0.1 µT (BMM350)
- Interface
- I2C (0x10 to 0x13 for BMM150, 0x14/0x15 for BMM350), SPI on BMM150
- Supply
- 1.62 to 3.6 V (modules 3.3 to 5 V)
- Current
- About 170 µA (BMM150) at 20 Hz
- Package
- Tiny WLCSP: use a module
Models in this guide
These are alternatives. Pick the one that fits your project; you only need one.
Option 1DFRobot Fermion BMM150 Triple Axis Magnetometer Sensor Breakout – I2C/SPI Interface₹819
Option 2DFRobot Gravity BMM150 Triple-Axis Magnetometer Sensor – I2C Interface₹1,309
Option 3DFRobot Gravity BMM350 Triple-Axis Magnetometer Sensor – I2C/I3C Interface₹1,149
Option 4Waveshare BMM150 3-Axis Magnetometer Sensor Module – I2C/SPI Digital Compass₹709
Option 5Mikroe GEOMAGNETIC CLICK (Mikroe-2935) – 3-Axis BMM150 Geomagnetic Sensor Board, I²C & SPI, Digital Compass & Magnetic Field Measurement, mikroBUS₹1,509
Option 6Bosch BMM150 3-Axis Geomagnetic Magnetometer Sensor, I2C/SPI Digital Output, ±1300 µT (X/Y) & ±2500 µT (Z), –40°C to 85°C₹60
What the BMM150 / BMM350 magnetometer is
A magnetometer sees the Earth's field (about 25 to 65 µT) plus the field of everything nearby: steel screws, speakers, motors and current-carrying wires. Calibration removes the constant offsets (hard iron) and the stretching (soft iron).
Heading = atan2(Y, X) only works when the board is level. On a tilted board, use pitch and roll from an accelerometer to correct it, or let a fusion filter do it.
BMM150 / BMM350 magnetometer pinout
The pins on the BMM150 / BMM350 magnetometer and what each one does.
| Pin | Function |
|---|---|
| VCC | Supply (3.3 or 5 V on modules) |
| GND | Ground |
| SDA / SCL | I2C data and clock |
| SDO / CSB | Address select or SPI pins (BMM150) |
| INT / DRDY | Interrupt and data-ready outputs (optional) |
- VCC
- Supply (3.3 or 5 V on modules)
- GND
- Ground
- SDA / SCL
- I2C data and clock
- SDO / CSB
- Address select or SPI pins (BMM150)
- INT / DRDY
- Interrupt and data-ready outputs (optional)
Wiring the BMM150 / BMM350 magnetometer
Most breakouts have pull-up resistors and a regulator, so they run from 3.3 V or 5 V. Bare sensor ICs are 3.3 V (or 1.8 V) only: solder them to a breakout first and use a level shifter with 5 V boards. Mount the sensor away from motors, speakers and power wires.
| BMM150 / BMM350 magnetometer pin | Arduino Uno | ESP32 |
|---|---|---|
| VCC | 5V (or 3.3V) | 3V3 |
| GND | GND | GND |
| SDA | A4 | GPIO 21 |
| SCL | A5 | GPIO 22 |
- VCC
- Arduino Uno:
- 5V (or 3.3V)
- ESP32:
- 3V3
- GND
- Arduino Uno:
- GND
- ESP32:
- GND
- SDA
- Arduino Uno:
- A4
- ESP32:
- GPIO 21
- SCL
- Arduino Uno:
- A5
- ESP32:
- GPIO 22
Example code
To calibrate, rotate the board slowly through all directions, note the minimum and maximum X and Y, and set each offset to (max + min) / 2. For the BMM350 use the DFRobot_BMM350 library.
#include <DFRobot_BMM150.h>
DFRobot_BMM150_I2C bmm(&Wire, I2C_ADDRESS_4); // 0x13 on DFRobot boards
float offX = 0, offY = 0; // fill in after calibration
void setup() {
Serial.begin(115200);
while (bmm.begin()) { Serial.println("BMM150 not found"); delay(1000); }
bmm.setOperationMode(BMM150_POWERMODE_NORMAL);
bmm.setPresetMode(BMM150_PRESETMODE_HIGHACCURACY);
}
void loop() {
sBmm150MagData_t m = bmm.getGeomagneticData();
float heading = atan2(m.y - offY, m.x - offX) * 180.0 / PI;
if (heading < 0) heading += 360;
Serial.print("Heading: "); Serial.println(heading, 0);
delay(200);
}Setup and tuning
do it with the sensor mounted in the final case, near its battery and motors.
add your local magnetic declination (about 0 to 2 degrees in India) for true north.
use accelerometer pitch and roll when the board is not level.
a wire carrying 1 A a few centimetres away shifts the reading noticeably.
What you need
Shop this list11 of 12 found in our store · ₹8,154
DFRobot Fermion BMM150 Triple Axis Magnetometer Sensor Breakout – I2C/SPI Interface: the part this guide coversDFRobot Fermion BMM150 Triple Axis Magnetometer Sensor Breakout – I2C/SPI Interface₹819
DFRobot Gravity BMM150 Triple-Axis Magnetometer Sensor – I2C Interface: another version this guide coversDFRobot Gravity BMM150 Triple-Axis Magnetometer Sensor – I2C Interface₹1,309
DFRobot Gravity BMM350 Triple-Axis Magnetometer Sensor – I2C/I3C Interface: another version this guide coversDFRobot Gravity BMM350 Triple-Axis Magnetometer Sensor – I2C/I3C Interface₹1,149
Waveshare BMM150 3-Axis Magnetometer Sensor Module – I2C/SPI Digital Compass: another version this guide coversWaveshare BMM150 3-Axis Magnetometer Sensor Module – I2C/SPI Digital Compass₹709
Mikroe GEOMAGNETIC CLICK (Mikroe-2935) – 3-Axis BMM150 Geomagnetic Sensor Board, I²C & SPI, Digital Compass & Magnetic Field Measurement, mikroBUS: another version this guide coversMikroe GEOMAGNETIC CLICK (Mikroe-2935) – 3-Axis BMM150 Geomagnetic Sensor Board, I²C & SPI, Digital Compass & Magnetic Field Measurement, mikroBUS₹1,509
Bosch BMM150 3-Axis Geomagnetic Magnetometer Sensor, I2C/SPI Digital Output, ±1300 µT (X/Y) & ±2500 µT (Z), –40°C to 85°C: another version this guide coversBosch BMM150 3-Axis Geomagnetic Magnetometer Sensor, I2C/SPI Digital Output, ±1300 µT (X/Y) & ±2500 µT (Z), –40°C to 85°C₹60
Bosch BMM150 3-Axis Digital Geomagnetic Sensor (Magnetometer), ±1300 µT, WJCSP-12 Package: another version this guide coversBosch BMM150 3-Axis Digital Geomagnetic Sensor (Magnetometer), ±1300 µT, WJCSP-12 Package₹203
ESP32-WROOM-32 38-pin development board: for Wi-Fi logging and dashboardsESP32-WROOM-32 38-Pin Development Board₹389- Uno R3 development board: the controller used in the wiring tableFind this part
DFRobot BMI323 6DOF IMU: for tilt compensation and 9-axis fusionDFRobot Gravity BMI323 6DOF IMU Sensor Module – I2C/UART, Plug & Play₹1,819Closest match, check the specs
0.96 inch OLED display 128x64: to show readings without a computer0.96" OLED Display 128x64₹139Closest match, check the specs
Dupont jumper wires: for the connectionsDupont Jumper Wires (40 pcs)₹49Closest match, check the specs
Alternatives and when to choose them
- QMC5883L compass: the common GY-271 module.
- HMC5883L compass: the original, now rare.
- Magnetometers and 9-axis IMUs: fused orientation options such as the BNO085.
Try it: I2c pullup calculator
Change the values and the diagram and results update as you type.
Common mistakes to avoid
- Skipping calibration and getting headings that are tens of degrees off.
- Mounting it beside a motor, speaker or steel screw.
- Using atan2 heading while the board is tilted.
- Confusing the BMM150 and BMM350 libraries and addresses.
Frequently asked questions
BMM150 or BMM350?
BMM350 for lower noise and better stability; BMM150 has more examples.
Why is my heading wrong?
Usually calibration, nearby metal, or tilt. Calibrate in place and add tilt compensation.
What is the I2C address?
0x10 to 0x13 for the BMM150 (set by pins), 0x14 or 0x15 for the BMM350.
Can it detect magnets?
Yes, it reads any magnetic field, so it also works as a magnet sensor.
Do I need an accelerometer?
Only if the board will not stay level.
Parts for this guide
- ₹819View
- ₹1,309View
- ₹1,149View
- ₹709View
Mikroe GEOMAGNETIC CLICK (Mikroe-2935) – 3-Axis BMM150 Geomagnetic Sensor Board, I²C & SPI, Digital Compass & Magnetic Field Measurement, mikroBUS₹1,509View
Bosch BMM150 3-Axis Geomagnetic Magnetometer Sensor, I2C/SPI Digital Output, ±1300 µT (X/Y) & ±2500 µT (Z), –40°C to 85°C₹60View- ₹203View
- ₹389View
- ₹359View
- ₹1,043View
- ₹139View
- ₹49View
Calculators
Keep learning
Sources
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.


