HMC5883L / QMC5883L compass module
3-axis magnetometer for compass heading. Most modules now carry the QMC5883L.
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.
Magnetoresistive elements change resistance with the strength of the magnetic field on each axis.
Key specifications
| Sensor spec | Value |
|---|---|
| Measures | Magnetic field on 3 axes |
| Interface | I2C |
| I2C address | 0x1E (HMC) or 0x0D (QMC) |
| Supply voltage | 3 to 5 V module |
| Watch out for | The two chips need different libraries |
Pinout
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
Builds that use it
Alternatives
- ICM-20948 9-axis IMUCompass plus accelerometer and gyroscope
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.
