If you have a motor and you’d like to know where the shaft position is, you are likely to turn to an optical encoder scheme. However, as [lingib] points out, you can also use a magnet and a magnetometer. You can see how it works in the video below.
The MLX90393 is a 3-axis hall effect device and, with a magnet on the shaft, the X and Y outputs of the spinning magnet will form a quadrature output that you can easily read.
The magnet is strong enough that the Earth’s magnetic field becomes negligible. Post-processing involves scaling the two inputs to the same amplitude and shifting them so they are centered on zero. Then the angle in radians is the atan2 function of the X and Y coordinates.
We are always entertained by how many ways there are to measure any particular physical quantity. If you want to know more about the hall effect, we have you covered. In addition to magnetic and optical, mechanical encoders are also common.