[RESOLVED] Problem with GY-271 compass module HMC5883L != QMC5883L

Hi everyones,

If your GY-271 send you some wrong datas or 0 with HMC5883L librarys, like mine i bought here :
https://www.ebay.com/itm/HMC5883L-Power-supply-3V-5V-Triple-Axis-Compass-Magnetometer-Sensor-Module/351494130125

This is because the main chip is not HMC5883L but QMC5883L.
Scanning i2C adress give 0x0D

You will find the right library here : GitHub - keepworking/Mecha_QMC5883L: Arduino lib for QMC5883

Maybe it can help :slight_smile:

Thanks a lot for solution.This method worked for me.

thanks body ,that was helpful & i wanted to ask you if you know how i can calibrate it :slight_smile:

Hi all - keep in mind that the QMC chip is vastly lower quality than the Honeywell original (lower sensitivity and lots of noise).

@asmaa1995 - there is a neat trick you can do which lets you avoid any need to calibrate.

Each pair of axes both have the same calibration needs, so when you apply a function using them both, the calibration "cancels out":-

Read_HMC5883L(); // Populates x,y,z

float bearing=((atan2(y,x))*180)/PI;//values will range from +180 to -180 degrees
if (bearing < 0) { bearing = 360 + bearing; }

float bearing2=((atan2(x,z))*180)/PI;//values will range from +180 to -180 degrees
if (bearing2 < 0) { bearing2 = 360 + bearing2; }

float bearing3=((atan2(z,y))*180)/PI;//values will range from +180 to -180 degrees
if (bearing3 < 0) { bearing3 = 360 + bearing3; }