Components / Sensors / HMC5883L / QMC5883L compass module

HMC5883L / QMC5883L compass module

3-axis magnetometer for compass heading. Most modules now carry the QMC5883L.

MeasuresMagnetic field on 3 axes
InterfaceI2C
I2C address0x1E (HMC) or 0x0D (QMC)
Supply voltage3 to 5 V module
SensorsReviewedMPN GY-271Used in 6 projects
HMC5883L
In short

What is the HMC5883L / QMC5883L compass module and what is it used for?

3-axis magnetometer for compass heading. Most modules now carry the QMC5883L. Makers use it for robot compass heading.

How it works

Magnetoresistive elements change resistance with the strength of the magnetic field on each axis.

Key specifications

Sensor specValue
MeasuresMagnetic field on 3 axes
InterfaceI2C
I2C address0x1E (HMC) or 0x0D (QMC)
Supply voltage3 to 5 V module
Watch out forThe two chips need different libraries

Pinout

VCC3 to 5 V
GNDGround
SCLI2C clock
SDAI2C data
DRDYData ready

How to use it

Run an I2C scan first: 0x1E means a genuine HMC5883L, 0x0D means the common QMC5883L, which needs a different library. Calibrate by rotating it through a full circle and subtracting the offsets, and tilt-compensate with an accelerometer.

Applications

Alternatives

Buy at

Common questions

What is the HMC5883L / QMC5883L compass module used for?

In maker projects: robot compass heading.

How does the HMC5883L / QMC5883L compass module work?

Magnetoresistive elements change resistance with the strength of the magnetic field on each axis.

What voltage does the HMC5883L / QMC5883L compass module need?

3 to 5 V module.

How do I connect the HMC5883L / QMC5883L compass module to an Arduino or ESP32?

I2C. Pins: VCC (3 to 5 V), GND (Ground), SCL (I2C clock), SDA (I2C data), DRDY (Data ready).

What can I use instead of the HMC5883L / QMC5883L compass module?

ICM-20948 9-axis IMU.