2D Compass using Magnetometer

Published Sep 05, 2018
 11 hours to build
 Intermediate

2D Compass using Magnetometer

display image

Components Used

HMC5883L Magnetometer Module
Magnetometer HMC5883L is developed by Honeywell. It gives the heading direction.
1
LCD 16x2 Display Module
LCD16x2 has two lines with 16 character in each line. LCD16x2 is generally used for printing values and string in embedded application.
1
ATmega 16
ATmega 16
1
Description

Overview

I made a simple and very interesting compass application using HMC5883L magnetometer which will show heading in degree.

Here, I am using Processing software to show the heading angle with visual compass in 2D on laptop’s display.

We need to send heading angle serially to computer where processing sketch is running. Using processing, read the heading angle continuously coming from serial port and plot them over 2D compass.

Interfacing Diagram

Magnetometer HMC5883L interfacing with ATmega16

 

Steps for Programming

  • Interfaced Magnetometer HMC5883L to ATmega16 and read the magnetic field along the X, Y and Z direction. This magnetic field is used to calculate the heading direction of the device.
  • Send this heading angle (direction) to laptop serially at 9600 baud rate and visualize them on Processing.

Program for 2D Compass using HMC5883L

  • Read HMC5883L using ATmega Microcontroller

Read data of HMC5883L magnetometer using Atmega16 microcontroller.

  • Visualize 2D Compass using Processing IDE

Here, I used processing software to visualize heading direction over compass. I read serial data continuously using processing and visualize them over compass in 360-degree direction.

I used one sample compass image over which these visualization is done.

Note: Refer following given program one for ATmega16 and other for Visualization of 2D Compass using Processing.

Video

Codes
Comments
Ad