Magnetic Field Measurement Using HMC5883 and Arduino Nano

The HMC5883is a digital compass designed for low-field magnetic sensing.This device has a wide magnetic field range of +/-8 Oe, and an output rate of 160 Hz. The HMC5883 sensor includes automatic degaussing strap drivers, offset cancellation, and a 12-bit ADC that enables 1° to 2° compass heading accuracy. All I²C Mini Modules are designed to operate at 5VDC.

Magnetic Field Measurement Using HMC5883 and Arduino Nano

In this tutorial we are going to explain the detailed working of HMC5883 with arduino nano.

Step 1: Hardware Required:

The materials that we need for accomplishing our goal includes the following hardware components:

1. HMC5883

2. Arduino Nano

3. I2C Cable

4. I2C Shield For Arduino Nano

Step 2: Hardware Hookup:

The hardware hookup section basically explains the wiring connections required between the sensor and the arduino nano. Ensuring correct connections is the basic necessity while working on any system for the desired output. So, the requisite connections are as follows:

The HMC5883 will work over I2C . Here is the example wiring diagram, demonstrating how to wire up each interface of the sensor.

Out-of-the-box, the board is configured for an I2C interface, as such we recommend using this hookup if you’re otherwise agnostic. All you need is four wires!

Only four connections are required Vcc, Gnd, SCL and SDA pins and these are connected with the help of I2C cable.

These connections are demonstrated in the pictures above.

Step 3: Arduino Code to Measure Magnetic Field Intensity:

Lets start with the arduino code now.

While using the sensor module with the arduino, we include Wire.h library. “Wire” library contains the functions which facilitate the i2c communication between the sensor and the arduino board.

The entire arduino code is given below for the convenience of the user:

Read more: Magnetic Field Measurement Using HMC5883 and Arduino Nano


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

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

Scroll to Top