Tag Archives: Digital Compass

Calibrating a 3-Axis Magnetometer

In this video lesson we show you how to calibrate the QMC5883L 3-axis magnetometer. The lesson is geared toward this specific magnetometer, but the procedure will be the same for any 3-axis magnetometer. We then use the calibrated reading to measure and calculate the magnetic heading of the device. With this, we have created a calibrated digital compass. In this lesson we are using the GY-87 module, which contains the QMC5883L magnetometer. We are connecting the module to the arduino using the following schematic:

MPU6050
Schematic for connecting the GY-87 module to the Arduino

In the video we develop two programs. The first program determines your sensor’s calibration constants. Then the second program uses those calibration constants to calculate heading, or yaw. The second program uses the offsets and scale parameters for MY PARTICULAR SENSOR. These values were determined using the first program. You must determine these values for your sensor, and then edit the second program to use your particular calibration parameters.

Program to determine your calibration parameters:

Once you get your calibration parameters, then put them into this program. This program will then calculate your compass heading: