system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: How does a compass on your phone work?
gpt
A pretty common method is to use magnetoresistance. Some materials change their electrical resistance depending on the direction of the magnetic field they're exposed to. So they put little slivers of those materials on a chip, at specific angles, along with circuitry to put a specific amount of current or voltage through the materials, and measure the how well electricity flows through them. Once they know that, the chip does the math to determine the precise 3D angle the magnetic field is pointing. The phone's CPU asks the chip for the compass data several times a second and averages it out to give you a smooth reading.