hmc5883l arduino,arduino compass,magnetometer arduino, compass navigation

(Last Updated On: April 9, 2021)

hmc588l arduino


HMC5883l Arduino- This Tutorial is about the HMC5883L magnetometer 3 axis sensor. This sensor is most commonly used in robotics for navigation purposes. Using this sensor you can easily find the direction. This tutorial covers the circuit connections, programming, and testing.

In this tutorial, you will learn how to use the HMC5883L magnetometer 3-axis sensor with Arduino.  In this tutorial you will also learn how to connect HMC5883L with Arduino, You will also learn how to use HMC588L to make a Compass. We will display the angle on the computer screen and will control an led when the compass is at a particular angle. Such a project can be easily modified in building an autonomous robot that can help a robot to turn at a particular angle. In this project, you will also learn to program.  In this tutorial, we will also discuss the ic2 communication bus, wiring, and programming.

Amazon Links:

Arduino Uno

Arduino Nano

HMC5883L Sensor:

Mega 2560:

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

About HMC5883L:

hmc588l arduino

The module includes a state-of-the-art, High-Resolution HMC118x series magneto-resistive sensor, Plus an ASIC containing amplification, Automatic degaussing strap Drivers, Offset cancellation, and a 12-bit ADC that enables 1 to 2-degree compass heading accuracy. The I2C serial bus allows for easy interface.


  1. The Honeywell HMC5883L is a surface mount, multi-chip module designed for low-field magnetic sensing with a digital interface for applications such as low cost compassing and magnetometry.
  2. The 12-Bit ADC coupled with low noise AMR sensors
  3. Low voltage operations and low power consumption, support built-in self-test.
  4. built-in strap drive circuits, wide magnetic field range, I2C digital interface
  5. working voltage 3.3v to 5v.

I2C Bus:

hmc588l arduino

I2C communication Bus has become very popular and now commonly used by thousands of electronic devices because of its easy implementation. By the easy implementation, I mean that such devices need only 2 wires. This way we can connect so many devices with for example Arduino using only two wires. Using the I2C communication bus we can connect many devices at the same time using only two wires as each device has its own unique address.

HMC5883L Arduino Connections Diagram:

hmc588l arduino

Arduino GND -> HMC5883L GND

Arduino 3.3V -> HMC5883L VCC

Arduino A4 (SDA) -> HMC5883L SDA

Arduino A5 (SCL) -> HMC5883L SCL

HMC5883L Arduino Programming:

Watch Video Tutorial:

Recommended For You

About the Author: Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

1 Comment

  1. You should include the HMC5883L.h library,as all the versions I found give upper / lower case errors and function not defined !

Leave a Reply

%d bloggers like this: