BMM150 strange data and bad north heading
I want to know where the north is for my project. I use a ESP32 and the DFRobot Gravity BMM150 3-Axis Magnetometer Sensor Module. But the uT values are off and the north heading is also not great. I do use the example code of the library “#include "DFRobot_BMM150.h"” Can someone help me?
For the normal values are between 25 and 60 but i get:
mag x = 31 uT
mag y = -11 uT
mag z = -25 uT
the angle between the pointing direction and north (counterclockwise) is:109.54
```
#include <Arduino.h>
#include <Wire.h>
#include "DFRobot_BMM150.h"
const int SDA_PIN = 14; // for I2C
const int SCL_PIN = 27; // for I2C
DFRobot_BMM150_I2C bmm150(&Wire, I2C_ADDRESS_4);
void setup()
{
Serial.begin(115200);
Wire.begin(SDA_PIN, SCL_PIN); // Initialize the I2C bus
while(!Serial);
while(bmm150.begin()){
Serial.println("bmm150 init failed, Please try again!");
delay(1000);
} Serial.println("bmm150 init success!");
bmm150.setOperationMode(BMM150_POWERMODE_NORMAL);
bmm150.setPresetMode(BMM150_PRESETMODE_HIGHACCURACY);
bmm150.setRate(BMM150_DATA_RATE_10HZ);
bmm150.setMeasurementXYZ();
}
void loop()
{
sBmm150MagData_t magData = bmm150.getGeomagneticData();
Serial.print("mag x = "); Serial.print(magData.x); Serial.println(" uT");
Serial.print("mag y = "); Serial.print(magData.y); Serial.println(" uT");
Serial.print("mag z = "); Serial.print(magData.z); Serial.println(" uT");
float compassDegree = bmm150.getCompassDegree();
Serial.print("the angle between the pointing direction and north (counterclockwise) is:");
Serial.println(compassDegree);
Serial.println("--------------------------------");
delay(500);
}
```
May I ask if you have a large number of running electrical appliances nearby, it is likely that you will not be able to get an accurate reading on the BMM150 if there is a lot of interference from the surrounding magnetic field.
Yeez_B