mprograms / QMC5883LCompass

QMC5883L Compass is a Arduino library for using QMC5583L series chip boards as a compass. Supports: - Getting values of XYZ axis. - Calculating Azimuth. - Getting 16 point Azimuth bearing direction (0 - 15). - Getting 16 point Azimuth bearing Names (N, NNE, NE, ENE, E, ESE, SE, SSE, S, SSW, SW, WSW, W, WNW, NW, NNW) - Smoothing of XYZ readings via rolling averaging and min / max removal. - Optional chipset modes
GNU General Public License v3.0
102 stars 39 forks source link

Bearing angle is not correct, except North=0 #30

Open gordon4liu opened 5 months ago

gordon4liu commented 5 months ago

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 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); }

microstoc commented 4 months ago

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