Based on the Honeywell HMC5883L, the GY-273 sensor module allows you add an electronic compass to your projects. While coding for the device can be a bit of a chore, there available libraries that make putting it to practical us a snap.
The device communicates with your Arduino via I2c.
This tutorial will show you how to connect the sensor and run sample sketch. It will also point you to a fantastic Adafruit library that will make using the device easy.
This is a pretty complicated device, that by itself could take pages to describe. This tutorial simply highlights the basics.
The Honeywell HMC5883L sensor used in the module is sensitive to the earths magnetic fields in three axes. These axes are labeled as X, Y, and Z. An output is provided for each of these axes that describes the position of these axes relative to the earth’s magnetic field.
As illustrated, twisting or turning the device will provide the corresponding outputs.