QMC5883LCompass icon indicating copy to clipboard operation
QMC5883LCompass copied to clipboard

Bearing angle is not correct, except North=0

Open gordon4liu opened this issue 1 year ago • 1 comments

Hi , At first , I run the calibration.ino ont the GY-271(QMC5883L). and get the calibration data. I copy its to bearing.ino.

And then I run the bearing.ino. The North is 0 deg, NE=2 deg, E=4, SE=5, S=6, SW=7, W=4, NW=8. Does it SW or HW issue??

=== bearing.ino == #include <QMC5883LCompass.h> QMC5883LCompass compass; void setup() { Serial.begin(9600); compass.init(); compass.setCalibrationOffsets(41.00, -159.00, -436.00); compass.setCalibrationScales(1.09, 0.93, 0.99); } void loop() { compass.read();

byte a = compass.getAzimuth(); // Output here will be a value from 0 - 15 based on the direction of the bearing / azimuth. byte b = compass.getBearing(a);

Serial.print("B: "); Serial.print(b); Serial.println();

delay(250); }

gordon4liu avatar Apr 01 '24 03:04 gordon4liu

I had what seems a similar problem. Rotating clockwise, the readings went N NE E SE S and then straight back to N. Nothing in the W region. Long story short, the azimuth readings were going 0 45 90 135 180 and then -180 -135 -90 -45. I corrected for this using ... if(azimuth<0){azimuth=360+azimuth};

HTH

microstoc avatar May 07 '24 23:05 microstoc