Overview

The QMC5883L is a 3-axis magnetic sensor IC manufactured by QST Corporation. Designed as a modern, pin-compatible alternative to the legacy Honeywell HMC5883L, it integrates anisotropic magnetoresistive (AMR) sensors with a 16-bit high-resolution ADC and signal processing ASIC.

It is widely found on cheap GY-271 breakout boards sold online as "HMC5883L modules". While physically similar, the QMC5883L operates on a different I2C slave address (0x0D instead of 0x1E) and uses different control register mappings.

Quick reference

Module VCC3.3 V to 5.0 V DC (onboard LDO)
Chip VDD2.16 V to 3.6 V DC
Field range±2.0 Gauss\pm 2.0\text{ Gauss} or ±8.0 Gauss\pm 8.0\text{ Gauss} (selectable via Control Register 1)
ADC resolution16-bit (3000 LSB/Gauss3000\text{ LSB/Gauss} sensitivity at ±2 G\pm 2\text{ G})
Output data rate10 Hz, 50 Hz, 100 Hz, or 200 Hz
Communication interfaceI2C (fixed address 0x0D, up to 400 kHz)
Operating current75 µA active, 3 µA standby

Pinout

Standard GY-271 5-Pin Breakout Header

PinNameTypeDescription
1VCCPowerSupply voltage (+3.3 V to +5.0 V DC)
2GNDPowerGround (0 V)
3SCLDigital InputI2C Serial Clock input
4SDADigital I/OI2C Serial Data line
5DRDYDigital OutputData Ready interrupt pin (Active-HIGH)

Specifications

ParameterSymbolMinTypMaxUnitConditions
Supply VoltageVDDV_{DD}2.163.03.6VDC
Operating CurrentIDDI_{DD}75100µAODR=10 HzODR = 10\text{ Hz}
Standby CurrentISTBI_{STB}310µAStandby mode
Full-Scale Range (RNG = 00)FSFS±2.0\pm 2.0Gauss
Full-Scale Range (RNG = 01)FSFS±8.0\pm 8.0Gauss
Field Sensitivity (2G Range)SS3000LSB/Gauss
Output Data RateODRODR10200HzConfigurable in Control Register 1

Register map (QMC5883L)

AddressRegisterAccessResetDescription
0x000x01OUT_X_L, OUT_X_HR0x00Output X Data (16-bit signed, Little-Endian)
0x020x03OUT_Y_L, OUT_Y_HR0x00Output Y Data (16-bit signed, Little-Endian)
0x040x05OUT_Z_L, OUT_Z_HR0x00Output Z Data (16-bit signed, Little-Endian)
0x06STATUSR0x00Status Register (DRDY bit 0 = Data Ready, OVL bit 1 = Overflow)
0x09CONTROL_1R/W0x00Mode, ODR, Range, Oversampling ratio
0x0ACONTROL_2R/W0x00Soft Reset, Pointer roll-over, Interrupt enable
0x0BSET_RESETR/W0x01Set/Reset Period register (Write 0x01 during init)
0x0DCHIP_IDR0xFFChip ID register (returns 0xFF)

Control Register 1 (0x09) Configuration

Bits [7:6] OSRBits [5:4] RNGBits [3:2] ODRBits [1:0] MODE
00 = 512 Oversampling00 = ±2 Gauss\pm 2\text{ Gauss}00 = 10 Hz00 = Standby Mode
01 = 256 Oversampling01 = ±8 Gauss\pm 8\text{ Gauss}01 = 50 Hz01 = Continuous Mode
10 = 128 Oversampling10 = Reserved10 = 100 Hz10 = Reserved
11 = 64 Oversampling11 = Reserved11 = 200 Hz11 = Reserved

To initialize for continuous 200 Hz reading at ±2 Gauss\pm 2\text{ Gauss} range with 512 oversampling: Write 0x1D to register 0x09 and 0x01 to register 0x0B.

Wiring

QMC5883L Module PinMicrocontroller (Arduino Uno / ESP32)
VCC3.3V (or 5V)
GNDGND
SCLSCL (A5 on Uno, GPIO22 on ESP32)
SDASDA (A4 on Uno, GPIO21 on ESP32)
Warning

Incompatibility with HMC5883L Libraries: The QMC5883L defaults to I2C address 0x0D and uses Little-Endian 16-bit register reads starting at 0x00 (X_LSB, X_MSB, Y_LSB, Y_MSB, Z_LSB, Z_MSB). Running standard HMC5883L code will fail to communicate. Ensure you install a QMC5883L specific library.

Common mistakes

  • Attempting to read from I2C address 0x1E: The QMC5883L responds on 0x0D.
  • Forgetting to set SET_RESET register (0x0B): Writing 0x01 to register 0x0B is required during setup to clear the AMR sensor offset.
  • Reading data in Big-Endian format: QMC5883L outputs Little-Endian bytes (LSB byte first, then MSB byte), opposite to the HMC5883L.

Notes

  • Compass Heading Formula: Heading (rad)=atan2(Y,X)\text{Heading (rad)} = \text{atan2}(Y, X). Convert to degrees: Heading (deg)=Heading (rad)×180π\text{Heading (deg)} = \text{Heading (rad)} \times \frac{180}{\pi}.

Assets & downloads