Skip to content

Latest commit

 

History

History
69 lines (47 loc) · 1.81 KB

README.md

File metadata and controls

69 lines (47 loc) · 1.81 KB

Arduino_BOSCH_BMM150

This is an Arduino library for the BOSCH BMM150 magnetometer like it is used in the Arduino Nano 33 BLE Sense. The library supports several ways of reading the sensor data,

This library uses the BOSCH BMM150 Sensor API.

Data sheets

Usage

Object creation

#include "bosch_bmm150.h"
andrgrue::sensor::bosch_bmm150 Mag(Wire1);

float mag_x, mag_y, mag_z;
andrgrue::sensor::bosch_bmm150::Data mag_data;

Setup

void setup() {

  // wire must be initialized first
  Wire1.begin();
  Wire1.setClock(400000);

  if(!Mag.initialize(BMM150_DATA_RATE_25HZ)) {
    Serial.println("MAG init failed!");
    while (1);
  }

  Serial.print("sample rate: mag=");
  Serial.println(Mag.magneticfieldSampleRate());
}

Loop

void loop() {

  if(Mag.magneticfieldAvailable()){
    Mag.magneticfield(mag_data);
  }

}

Credits

This project was inspired and includes several elements from the following projects. Special thanks to the authors.

License

Copyright © 2024, André Grüttner. All rights reserved.

This project is licensed under the GNU Lesser General Public License v2.1 (LGPL-2.1). You may use, modify, and distribute this software under the terms of the LGPL-2.1 license. See the LICENSE file for details, or visit GNU’s official LGPL-2.1 page for the full license text.