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
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.