Hi all,
I'm encountering an issue with my compass angle calculation using the BMM350 magnetometer. The code snippet below is supposed to compute the compass heading based on the magnetic sensor data, but the resulting angle only reflects half of the actual rotation. For example, when rotating the device 360 degrees, the compass displays only 180 degrees. I'm seeking help to identify the root cause and resolve this problem.
float compass = 0.0;
sBmm350MagData_t magData = getGeomagneticData();
compass = atan2(magData.x, magData.y) * 180 / M_PI;
if (compass < 0) {
compass += 360;
}
if (compass > 360) {
compass -= 360;
}
return compass;
Has anyone encountered a similar issue with the BMM350 or other magnetometers?
Are there known calibration steps or sensor-specific configurations needed for accurate readings?
Could the issue stem from hardware limitations or firmware settings?