BMM150 3-Axis Magnetometer Sensor

From Waveshare Wiki
Revision as of 14:38, 31 August 2023 by Waveshare-admin (talk | contribs) (Text replacement - "https://www.waveshare.com/w/upload/" to "https://files.waveshare.com/upload/")
Jump to: navigation, search
BMM150 3-Axis Magnetometer Sensor
BMM150 3-Axis Magnetometer Sensor.png

I2C, SPI
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

Overview

Introduction

The BMM150 is a 3-axis magnetometer sensor, with the features of ultra-small form factor, low power consumption, and low noise. This digital high-performance sensor is ideal for a variety of altitude-tracking applications. Supports both I2C / SPI interfaces, compatible with 3.3V/5V voltage levels. It can be easily integrated into projects such as GPS modules, wearables devices, audible devices, and drones, suitable for applications such as accurate altimeters, environment monitoring, and IoT projects.

Feature

  • Support I2C/SPI interface communication, I2C interface by default.
  • Onboard voltage translator, compatible with 3.3V/5V operating voltage.
  • Provide online user manuals and resources (Raspberry/Arduino/pico demo and manual).

Parameters

  • Operating voltage: 5V/3.3V
  • Communication interface: I2C/SPI
  • Resolution: 0.3μT
  • Linearity: <1%FS
  • Gain error: ±2%
  • Temperature drift sensitivity: ±0.01%/K
  • Zero point drift: ±40μT(25℃)
  • Measuring range: ±1300μT (x,y-axis), ±2500μT (z-axis)
  • Data output rate: 10Hz(normal mode: Regular preset)
  • Operating temperature: -40~85℃
  • Dimensions: 29mm × 20mm

Interface Description

Pin Description
VCC Power input
GND GND
SDA I2C data
SCL I2C clock
INT Interrupt output, can be connected to I/O
SDO SPI data, can be connected to the host MISO
SDI SPI data, can be connected to the host MOSI
CS Chip selection, can be connected to I/O
DRY Data sending/receiving ready state, can be connected to I/O

Working with Raspberry Pi

Function Library Installation

  • Install wiringPi:
sudo apt-get install wiringpi
#For the Raspberry Pi 4B it may be necessary to upgrade:
wget https://project-downloads.drogon.net/wiringpi-latest.deb
sudo dpkg -i wiringpi-latest.deb
gpio -v
# Run gpio -v and version 2.52 will appear, if it does not appear, it means there is an installation error

Preparation

Run the commands below to configure the Raspberry Pi:

sudo raspi-config 

Choose Interfacing Options -> I2C -> Yes to enable the I2C kernel driver.
Choose Interfacing Options -> SPI -> Yes to enable the SPI kernel driver.
Save and then exit, reboot the Raspberry Pi:

sudo reboot 

After rebooting, check whether SPI can be normally enabled:

ls /dev/spi*

BMM150 3-Axis Magnetometer Sensor01.png

WiringPi Demo

Download the example demo and unzip:

sudo apt-get update
sudo apt-get unzip
wget https://files.waveshare.com/upload/6/67/BMM150_3-Axis_Magnetometer_Sensor_code.zip
unzip BMM150_3-Axis_Magnetometer_Sensor_code.zip

I2C

Module Raspberry Pi
VCC 3.3V/5V
GND GND
SDA SDA
SCL SCL
INT NC

  • Check the connection:
i2cdetect -y 1

BMM150 3-Axis 04.png
The I2C address of the module is 0x13 and can be modified by changing the level of A0/SD0 and A1/CS. Then you can modify it in the corresponding bmm150_common.c code.
BMM150 3-Axis 05.png
BMM150 3-Axis 06.png

/*! @name I2C ADDRESS       */
#define BMM150_DEFAULT_I2C_ADDRESS                UINT8_C(0x10)
#define BMM150_I2C_ADDRESS_CSB_LOW_SDO_HIGH       UINT8_C(0x11)
#define BMM150_I2C_ADDRESS_CSB_HIGH_SDO_LOW       UINT8_C(0x12)
#define BMM150_I2C_ADDRESS_CSB_HIGH_SDO_HIGH      UINT8_C(0x13)
  • Enter the I2C directory, compile, and then run the demo:
cd
cd BMM150_3-Axis_Magnetometer_Sensor_code/RaspberryPi/I2C
  • Run the demo:
make clean 
make
sudo ./bmm150 
  • The data is displayed as shown below:

BMM150 3-Axis 07.png
Wait for a while to get stable data. From left to right, the magnetic inductance measured by BMM150 in X, Y, and Z axes is shown.

SPI

The module is in I2C mode by default and you can change to SPI mode in the left upper corner when selecting the pad.

Module Raspberry Pi
VCC 3.3V
GND GND
SDO MISO
SDI MOSI
SCK SCLK
CS 27 (wiringPi code)

  • Enter the SPI directory to compile and run the demo:
cd
cd BMM150_3-Axis_Magnetometer_Sensor_code/RaspberryPi/SPI
  • Run the demo:
make clean 
make
sudo ./bmm150 
  • The data is displayed below:

BMM150 3-Axis 08.png
After waiting for a minute, you can get stable data. From left to right, the magnetic inductance measured by the BMM150 in the X, Y, and Z axes is shown.

Python

Module Raspberry Pi
VCC 3.3V/5V
GND GND
SDA SDA
SCL SCL
INT NC

  • Check the connection:
i2cdetect -y 1

BMM150 3-Axis 04.png
Enter the Python demo file and run it:

cd RaspberryPi/python
sudo python get_geomagnetic_data.py

And then you can get the data:
BMM150 3-Axis 10.png
Wait for a while to get stable data. The module displays the measured magnetic induction intensity of the three axes in sequence.

Working with Arduino

I2C

  • Connect the module to the Arduino development board as shown below:
Module Arduino
VCC 5V
GND GND
SDA SDA
SCL SCL
INT NC

BMM150 3-Axis 11.png

  • After correctly connecting and checking the communication way and device address, you can compile and download to Arduino.
  • Open Tool -> SSCOM, choose the baud rate as 115200, and you can get the following information:

BMM150 3-Axis p0.png
Wait for a while to get stable data. From left to right, the magnetic inductance measured by BMM150 in X, Y, and Z axes are shown.
If the data is not displayed successfully, or if the data is not displayed properly, please check the connection, communication method, and device address for errors.

SPI

The module defaults to I2C mode and can be switched to SPI mode by modifying the mode selection pads in the upper left corner.

Module Arduino
VCC 3.3V
GND GND
SDO 12
SDI 11
SCK 13
CS 10

BMM150 3-Axis20.png

  • After wiring the device correctly and determining the communication method and the device address, open the corresponding demo for Arduino, make sure the macro definition USE_I2C is 0 in the program, compile it, and download it to the Arduino development board.
  • Open Tools -> Serial Monitor, and select baud rate 115200, you can get the following information.

BMM150 3-Axis21.png
Wait for a while to get stable data. From left to right, the magnetic inductance measured by BMM150 in X, Y, and Z axes is shown.
If the data is not displayed successfully, or if the data is not displayed properly, please check the connection, communication method, and device address for errors.

ESP32

ESP32-S3-DEV-KIT-N8R8 development board is used in this demo.

I2C

Module ESP32
VCC 5V
GND GND
SDA 13
SCL 14
INT NC

BMM150 3-Axis023.png

  • After wiring the device correctly and determining the communication method and device address, open the corresponding demo of ESP32, make sure the macro definition USE_I2C is 1, compile and download it to Arduino.
  • Open Tools -> Serial Monitor, and select baud rate 115200, you can get the following information.

BMM150 3-Axis024.png
Wait for a while to get stable data. From left to right, the magnetic inductance measured by BMM150 in X, Y, and Z axes is shown.
If the data is not displayed successfully, or if the data is not displayed properly, please check the connection, communication method, and device address for errors.

SPI

The module defaults to I2C mode and can be switched to SPI mode by modifying the mode selection pads in the upper left corner.

Module ESP32-S3
VCC 5V
GND GND
SDO 10
SDI 11
SCK 9
CS 12

BMM150 3-Axis025.png

  • After the correct wiring, determining the communication method and the device address, open the corresponding demo of ESP32, make sure the macro definition USE_I2C is 0, compile, and download to ESP32.
  • Open: Tools -> Serial Monitor, select baud rate 115200, and you can get the following information:

BMM150 3-Axis026.png
Wait for a while to get stable data. From left to right, the magnetic inductance measured by BMM150 in X, Y, and Z axes is shown.
If the data is not displayed successfully, or if the data is not displayed properly, please check the connection, communication method, and device address for errors.

Working with Raspberry Pi Pico

Software Preparation

Install Thonny

  • Enter Thonny website to download.
  • Also, you can click here to download.

Program MicroPython Firmware

  • Online installation: the newest Thonny version can automatically download the firmware.
  1. First, you need to press and hold the boot button of the Pico while connecting the Pico to the PC using the USB cable.
  2. After that, open Thonny and click Tool -> Options... -> Interpretere -> INstall or update MicroPython.
  3. In the pop-up window, select the corresponding development board and MicorPython version, and click Install, then wait for the installation to finish.

BMM150 3-Axis30.png
If the software installation MicroPython window keeps prompting downloading variants info... and there is no change for a long time, you can choose to use a proxy or use the following offline installation method instead.

  • Off-line installation method:
  1. Download the firmware and get a .uf2 file.
  2. Press the boot button of the Pico, connect the Pico to the PC with a USB cable, and then a USB storage device appears on the computer.
  3. Open the device folder, and drag the ".uf2" file directly into the folder. After that, the storage device automatically popped up, and the development board reboots, at this time the installation is finished. You can open Thonny to see whether Pico's micro python environment is successfully recognized. For more details, please refer to Pico's website.

Hardware Connection

Module Pico
VCC 5V
GND GND
SDA GP2
SCL GP3
INT NC

BMM150 3-Axis 27.png

Demo Use

As shown in the picture:

  1. Verify that a Raspberry Pi Pico development board with Micropython firmware written to it is connected.
  2. Open the unzipped sample demo folder in the upper left corner of the file screen and open the Pico folder.
  3. Select the two .py files and right-click on them and select Upload.
  4. Open the example demo "get_geomagnetic_data.py" by double-clicking on the in-chip file screen at the bottom left after uploading.
  5. Click the above button to run.

BMM150 3-Axis 28.png

Resource

Document

Demo

Software

Related File

Support



Technical Support

If you need technical support or have any feedback/review, please click the Submit Now button to submit a ticket, Our support team will check and reply to you within 1 to 2 working days. Please be patient as we make every effort to help you to resolve the issue.
Working Time: 9 AM - 6 PM GMT+8 (Monday to Friday)