RASPBERRY PI AND SENSE HAT(III): WORKING WITH THE MAGNETOMETER
- Layout for this exercise:

1 - Introduction
- A magnetometer is an instrument that measures magnetism, either magnetization of magnetic material like a ferromagnet, or the direction, strength, or the relative change of a magnetic field at a particular location.
- A compass is a simple example of a magnetometer, one that measures the direction of an ambient magnetic field.
https://en.wikipedia.org/wiki/Magnetometer
2 - Magnetic North
- The function get_compass() gets the direction of North from the magnetometer in degrees. On the other hand, the function get_compass_raw() gets the raw XYZ axis magnetometer data:


- Giving execution permissions:

- Running the program:

2 - Sensing a magnet
- The function get_compass_raw() detects the presence of a magnet. For instance when the reading for the Z axis is higher than an established limit, turning the LED matrix with red light (255,0,0) every 0.1 second:


- Giving execution permissions:

- Running the program when a magnet is getting closer vertically to the Sense Hat module:

