Zbotic Logo Zbotic Logo
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

  • Shop
  • About Us
  • Contact Us
  • Reseller
  • Blogs
020 69134444
1800 209 0998
[email protected]
Help Desk
Facebook Twitter Instagram Linkedin YouTube
Zbotic Logo Zbotic Logo
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

All departments
  • 3D Print Service
  • 3D Printer
  • Batteries & Chargers
  • Development Boards
  • Drone Parts
  • EBike parts
  • Sensor Modules
  • Electronic Components
  • Electronic Modules
  • IoT and Wireless
  • Mechanical Parts and Workbench Tools
  • Motors & Drivers & Pumps & Actuators
  • DIY and Robot Kits
  • Show more
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
Return to previous page
Home Sensors & Modules

HMC5883L vs QMC5883L: 3-Axis Magnetometer Comparison for Arduino

HMC5883L vs QMC5883L: 3-Axis Magnetometer Comparison for Arduino

March 11, 2026 /Posted byJayesh Jain / 0

If you have ever ordered a GY-273 magnetometer module expecting to get an HMC5883L and ended up with code that does not work, you have stumbled into one of the most confusing situations in the maker electronics world. The HMC5883L from Honeywell and the QMC5883L from QST Corporation look identical on the breakout board, have almost identical names, but are fundamentally different ICs with different I2C addresses, different register maps, and different initialisation sequences. This comprehensive guide explains exactly how to identify which chip you have, shows you how to wire and code both correctly, and helps you build a tilt-compensated digital compass that works reliably with Arduino.

Table of Contents

  1. How to Identify HMC5883L vs QMC5883L
  2. Specifications Comparison
  3. HMC5883L: Wiring and Initialisation
  4. QMC5883L: Wiring and Initialisation
  5. Arduino Code for HMC5883L
  6. Arduino Code for QMC5883L
  7. Magnetometer Calibration: Hard-Iron and Soft-Iron
  8. Tilt Compensation with Accelerometer
  9. Magnetic Declination for Indian Cities
  10. Troubleshooting Common Problems
  11. FAQ

1. How to Identify HMC5883L vs QMC5883L

The GY-273 PCB silkscreen often says “HMC5883L” even when the actual chip is a QMC5883L. The easiest way to check is through software:

#include <Wire.h>

void setup() {
  Wire.begin();
  Serial.begin(115200);
  // HMC5883L is at 0x1E; QMC5883L is at 0x0D
  for (byte addr : {0x0D, 0x1E}) {
    Wire.beginTransmission(addr);
    byte err = Wire.endTransmission();
    if (err == 0) {
      Serial.print("Device found at 0x");
      Serial.println(addr, HEX);
      if (addr == 0x1E) Serial.println("→ This is an HMC5883L");
      if (addr == 0x0D) Serial.println("→ This is a QMC5883L");
    }
  }
}
void loop() {}

You can also check physically: if you have a magnifier or USB microscope, look at the IC markings. HMC5883L usually has “5883” or “H5883” visible; QMC5883L chips often show “QMC” or “Q5883”.

A third method: read the identification register. For HMC5883L, register 0x0A returns 0x48 (‘H’). The QMC5883L has a Chip ID register at 0x0D that returns 0xFF on most samples.

2. Specifications Comparison

Specification HMC5883L QMC5883L
Manufacturer Honeywell QST Corporation
I2C address 0x1E (fixed) 0x0D (fixed)
Measurement range ±1.3 to ±8.1 Gauss (7 options) ±2 / ±8 Gauss (2 options)
Resolution 12-bit (2 mG/LSB at ±1.3G range) 16-bit (1 µT / 10 LSB)
Output data rate 0.75, 1.5, 3, 7.5, 15, 30, 75 Hz 10, 50, 100, 200 Hz
Supply voltage 2.16–3.6 V (I2C: 1.71–3.6 V) 2.16–3.6 V
Current (active) 100 µA ~100 µA at 10 Hz
Temperature range -30°C to +85°C -40°C to +85°C
Temperature sensor No Yes (16-bit, for compensation)
Self-test Yes (internal field) Yes
DRDY pin Yes (data ready interrupt) Yes
Register map Unique (incompatible) Unique (incompatible)
Current availability Discontinued by Honeywell In production

Key takeaway: The QMC5883L is not an HMC5883L clone in any functional sense — it has a different address, different registers, and a higher data rate. The HMC5883L has been discontinued by Honeywell, so the vast majority of GY-273 modules being sold today in India contain the QMC5883L.

3. HMC5883L: Wiring and Initialisation

The GY-273 module includes a 3.3 V LDO and I2C pull-ups, making it safe to connect directly to 5 V Arduino boards.

GY-273 (HMC5883L) → Arduino Uno
VCC  → 5 V (module has onboard 3.3 V LDO)
GND  → GND
SCL  → A5
SDA  → A4
DRDY → D2 (optional, for interrupt-driven reads)

The I2C address is fixed at 0x1E — there is no address selection pin. This means you can only have one HMC5883L on the same I2C bus (unless you use an I2C multiplexer like the TCA9548A).

4. QMC5883L: Wiring and Initialisation

Wiring is identical to the HMC5883L — same GY-273 board layout, same pins. The only difference is the I2C address in your code:

GY-273 (QMC5883L) → Arduino Uno
VCC  → 5 V
GND  → GND
SCL  → A5
SDA  → A4
// I2C address in code: 0x0D (NOT 0x1E!)

The QMC5883L also has a SET/RESET pin (sometimes labelled SETP) that connects to a capacitor on the module for demagnetisation. The GY-273 module handles this with a capacitor already on the PCB — do not connect any external circuitry to this pin.

5. Arduino Code for HMC5883L

Install the QMC5883LCompass library (ironically, it supports both chips) or use the Adafruit HMC5883 Unified library.

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_HMC5883_U.h>

Adafruit_HMC5883_Unified mag(12345);

void setup() {
  Serial.begin(115200);
  if (!mag.begin()) {
    Serial.println("HMC5883L not found! Check wiring and address.");
    while (1);
  }
  sensor_t sensor;
  mag.getSensor(&sensor);
  Serial.print("Sensor: "); Serial.println(sensor.name);
}

void loop() {
  sensors_event_t event;
  mag.getEvent(&event);
  // Heading in degrees (0 = North)
  float heading = atan2(event.magnetic.y, event.magnetic.x) * 180.0 / PI;
  if (heading < 0) heading += 360;
  Serial.print("Heading: "); Serial.print(heading, 1); Serial.println("°");
  // Raw field components
  Serial.print("X: "); Serial.print(event.magnetic.x); Serial.print(" µT  ");
  Serial.print("Y: "); Serial.print(event.magnetic.y); Serial.print(" µT  ");
  Serial.print("Z: "); Serial.println(event.magnetic.z);
  delay(200);
}

6. Arduino Code for QMC5883L

Install the QMC5883LCompass library by MPrograms from the Library Manager:

#include <QMC5883LCompass.h>

QMC5883LCompass compass;

void setup() {
  Serial.begin(115200);
  Wire.begin();
  compass.init();           // Connects to 0x0D, sets continuous mode
  compass.setMode(0x01,     // Continuous mode
                  0x0C,     // 200 Hz ODR
                  0x10,     // ±8 Gauss range
                  0x00);    // Oversampling ratio 512
}

void loop() {
  compass.read();
  int x = compass.getX();
  int y = compass.getY();
  int z = compass.getZ();
  // Heading
  float heading = atan2((float)y, (float)x) * 180.0 / PI;
  if (heading < 0) heading += 360.0;
  Serial.print("Heading: "); Serial.print(heading, 1); Serial.print("°  ");
  Serial.print("X: "); Serial.print(x); Serial.print("  ");
  Serial.print("Y: "); Serial.print(y); Serial.print("  ");
  Serial.print("Z: "); Serial.println(z);
  delay(100);
}

The QMC5883L returns raw 16-bit signed integers in LSB units. To convert to µT: multiply by the scale factor for your chosen range (±2G: 0.0833 µT/LSB; ±8G: 0.333 µT/LSB).

BME280 sensor

GY-BME280-3.3 Precision Altimeter Sensor Module

Pair your magnetometer with a BME280 for weather-aware navigation projects. Shares the I2C bus at a different address, so both sensors work simultaneously.

View on Zbotic

7. Magnetometer Calibration: Hard-Iron and Soft-Iron

Without calibration, a magnetometer compass will be wildly inaccurate. Calibration corrects two types of distortion:

Hard-Iron Distortion

Caused by permanently magnetised materials near the sensor (speaker magnets, steel chassis, PCB copper pours). This creates a constant offset in all readings, shifting the measurement sphere off-centre. Correction: find the offset by rotating the sensor through all orientations and computing the centre of the data ellipsoid.

// Hard-iron calibration: collect data while rotating slowly
// in all orientations (flip upside down, rotate 360° on each axis)
int xMin = 32767, xMax = -32768;
int yMin = 32767, yMax = -32768;
// After collection:
float xOffset = (xMax + xMin) / 2.0;
float yOffset = (yMax + yMin) / 2.0;
// Apply: corrX = rawX - xOffset; corrY = rawY - yOffset;

Soft-Iron Distortion

Caused by magnetically permeable materials (soft iron, certain alloys) that distort the shape of the Earth’s field around the sensor. This stretches the sphere of raw measurements into an ellipsoid. Correcting it requires a 3×3 scaling matrix, but for most maker applications, a simple axis scaling approximation is sufficient:

// Soft-iron scale factors (computed from ellipsoid axes)
float xScale = 2.0 / (xMax - xMin);
float yScale = 2.0 / (yMax - yMin);
// Apply: scaledX = (rawX - xOffset) * xScale
//        scaledY = (rawY - yOffset) * yScale

After full calibration, the heading formula gives results accurate to within 2–5° in environments with moderate magnetic interference. For best results, calibrate the sensor in its final mounted position (inside your robot, PCB assembly, etc.) rather than in the open air.

8. Tilt Compensation with Accelerometer

A plain magnetometer compass only works when the sensor is perfectly horizontal. Tilting it changes the projection of the Earth’s magnetic field on the X-Y plane, giving large heading errors. The fix is tilt compensation using accelerometer data:

// Roll and pitch from accelerometer (in radians)
float roll  = atan2(ay, az);
float pitch = atan2(-ax, sqrt(ay*ay + az*az));

// Tilt-compensated magnetic components
float Xh = mx * cos(pitch) + mz * sin(pitch);
float Yh = mx * sin(roll) * sin(pitch) + my * cos(roll)
           - mz * sin(roll) * cos(pitch);

// Tilt-compensated heading
float heading = atan2(Yh, Xh) * 180.0 / PI;
if (heading < 0) heading += 360.0;

Where ax, ay, az are accelerometer readings in g, and mx, my, mz are calibrated magnetometer readings. The GY-273 does not have an accelerometer, so combine it with an ADXL345, MPU6050, or MPU9250 for tilt-compensated operation.

9. Magnetic Declination for Indian Cities

Magnetic north differs from geographic (true) north by the magnetic declination angle, which varies by location. In India, the declination is westward (negative), meaning magnetic north points slightly west of true north. Add the declination to your compass heading to get true north:

City Declination (2025) Heading Correction
Mumbai 0.9° W Subtract 0.9°
Delhi 0.5° W Subtract 0.5°
Bengaluru 0.7° W Subtract 0.7°
Chennai 0.5° W Subtract 0.5°
Hyderabad 0.6° W Subtract 0.6°
Kolkata 0.3° E Add 0.3°
Ahmedabad 0.8° W Subtract 0.8°

In code: trueHeading = magneticHeading + declination; where declination is positive for East, negative for West. Look up your exact declination at ngdc.noaa.gov/geomag/calculators/magcalc.shtml.

BMP280

BMP280 Barometric Pressure and Altitude Sensor

Combine with your magnetometer for a full compass and altimeter setup. Perfect for hiking GPS loggers and drone navigation systems.

View on Zbotic

10. Troubleshooting Common Problems

Symptom Cause Fix
Library not finding sensor Wrong I2C address (HMC vs QMC mix-up) Run I2C scanner, use matching library
Heading jumps wildly Uncalibrated / no hard-iron correction Perform full rotation calibration
Large heading error when tilted No tilt compensation Add ADXL345/MPU6050 + tilt formula
Always reads 0 on all axes Chip in standby/single-shot mode, not continuous Set continuous mode in Control Register A
Compass heading off by ~180° Module mounted upside down Negate both X and Y axis, or flip board
Readings change when motors run Motor electromagnetic interference Move sensor far from motors; add ferrite bead on VCC

FAQ

Can I use the HMC5883L library with a QMC5883L chip?

No — the register maps and I2C addresses are completely different. Using the wrong library will produce incorrect or zero readings. Always identify your chip first (I2C scanner at 0x0D vs 0x1E) and use the matching library. The QMC5883LCompass library supports the QMC5883L specifically.

Why is the HMC5883L discontinued?

Honeywell discontinued the HMC5883L (and its successors HMC5983) around 2020, shifting focus to higher-end military and industrial magnetometer products. The QMC5883L from QST fills the low-cost maker segment and is the chip you will almost certainly receive when ordering a GY-273 module today in India.

Can I have two magnetometers on the same I2C bus?

Only if they have different addresses. One HMC5883L (0x1E) and one QMC5883L (0x0D) can coexist. Two HMC5883L chips cannot share an I2C bus without an I2C multiplexer (TCA9548A) because the address is fixed. Two QMC5883L chips face the same issue.

How do I reduce compass error near motors and electronics?

Mount the magnetometer as far as physically possible from DC motors, Li-Po batteries, and large current-carrying traces. Use twisted pair cables to the module. Shield the module enclosure with mu-metal foil if extreme accuracy is needed. Calibrate the compass in its final installed position inside the robot/drone — nearby magnetic materials alter the hard-iron offset significantly.

Which magnetometer is more accurate: HMC5883L or QMC5883L?

The QMC5883L has higher native resolution (16-bit vs 12-bit) and a higher maximum output data rate (200 Hz vs 75 Hz), which are advantages on paper. However, absolute accuracy depends much more on calibration quality than on native resolution. In practice both sensors, when properly calibrated and tilt-compensated, achieve compass accuracy of 1–3° — adequate for all but the most demanding navigation applications.

Build Your Digital Compass Project

Whether you need a magnetometer for a compass, a drone, or a navigation system, Zbotic stocks GY-273 modules and all supporting sensors across India. Get started with fast delivery and expert support.

Shop Sensors & Modules

Tags: Arduino, digital compass, HMC5883L, magnetometer, QMC5883L
Share Post
  • Facebook
  • Linkedin
  • Whatsapp
Thermistor vs Thermocouple vs ...
blog thermistor vs thermocouple vs rtd which industrial temperature sensor should you choose 596183
blog mg90s metal gear servo installation specs robotic uses in india 596185
MG90S Metal Gear Servo: Instal...

Related posts

Svg%3E
Read more

Encoder Module: Position and Speed Measurement with Arduino

April 1, 2026 0
A rotary encoder converts the angular position and rotation speed of a shaft into electrical signals that Arduino can count... Continue reading
Svg%3E
Read more

Infrared Obstacle Sensor: Line Follower and Object Detection

April 1, 2026 0
Infrared obstacle sensors are the building blocks of line-following robots, edge detection systems, and proximity triggers. These tiny modules emit... Continue reading
Svg%3E
Read more

Rain Sensor and Raindrop Detection Module: Arduino Guide

April 1, 2026 0
A rain sensor module detects the presence of water droplets on its surface, giving Arduino a simple signal to trigger... Continue reading
Svg%3E
Read more

LiDAR Sensor TFmini: Distance Measurement Beyond Ultrasonic

April 1, 2026 0
When ultrasonic sensors hit their limits — range too short, accuracy too coarse, outdoor sunlight causing interference — LiDAR sensors... Continue reading
Svg%3E
Read more

Pressure Sensor BMP280: Weather Station and Altitude Meter

April 1, 2026 0
The BMP280 barometric pressure sensor by Bosch measures atmospheric pressure with ±1 hPa accuracy and temperature with ±1°C precision. These... Continue reading

Add comment Cancel reply

Your email address will not be published. Required fields are marked

Facebook Twitter Instagram Pinterest Linkedin Youtube

Get the latest deals and more.

Download on Google Play Download on the App Store

Call us: 020 69134444 / 1800 209 0998

Monday - Saturday 09:30 AM - 06:00 PM
For Technical Supports Email: [email protected]
For Sales / Enquiries Email: [email protected]

  • My Account

    • Cart

    • Wishlist

    • Checkout

    • My Orders

    • Track Order

    • My Account

  • Information

    • FAQs

    • Blogs

    • Career

    • About Us

    • Contact Us

    • Payment Options

  • Policies

    • Privacy Policy

    • Terms & Conditions

    • GST Input Tax Credit

    • Shipping Return Policy

    • E-Waste Collection Points

    • Our Sitemap

© Zbotic.in is registered trademark of Moxie Supply Pvt Ltd – All Rights Reserved
Login
Use Phone Number
Use Email Address
Not a member yet? Register Now
Reset Password
Use Phone Number
Use Email Address
Register
Already a member? Login Now