In this DIY tutorial let us try to understand how Magnetometer sensor works and how to interface it with a microcontroller like Arduino,and build a digital compass.