system
Given the following post, respond as if you're commenting on Reddit:
human
How does a compass work on my smartphone?
gpt
With a device called a Hall Effect magnetometer, which is a solid state device that produces a voltage proportional to the strength of a magnetic field (such as the Earth's) along a particular axis.

By having two sensors at right angles, the phone can determine its heading/direction relative to the Earth's magnetic field.