An ordinary compass works thanks to earth magnetism. The idea is that the compass reads which direction the magnetic field is relative to the compass. As a result, the arrow always points to magnetic north. Not the North Pole, but the local magnetic north. That way you can figure out what north, east, south and west is, and it's easier to understand where you are or where you need to go.
It works in a similar way in a smartphone . There is a compass chip in a phone that senses the magnetic field in two or three axes. The chip reads the magnetic field in each axis and converts it into information that the phone can process. You see an old-fashioned compass on your screen, although most phones give away a little more information.
That compass chip is also called the magnetometer, with which the phone can show where you are quite accurately. At least if your phone has one, because not all phones are equipped with it as standard. Most do, but there are exceptions, such as the Motorola G4. Although you may never map out a walk with a compass yourself, that chip will come in handy. This is useful, for example, if you use a navigation app , so that the point is in the right direction, although it is often stated that certainly not all Maps apps use this and GPS will also take you far.
If you really want to see a compass on your phone, many phone makers do offer a compass. iPhones have a compass installed by default, which you can find by going to the default compass app. Samsung has it in its Quick Tools, but if you want to use a compass on a OnePlus, for example, you must download a compass app from the Google Play Store.
Now, these kinds of apps are in abundance, so you can find a suitable variant quite quickly. Some well-known names are Compass Galaxy, Digital Compass and Compass. Often they can even show how high you are, because it is useful when you go to the mountains. Also, many compass apps, if you give permission, even show the address where you are. That does take the charm and the game away from puzzle games, but if you're in need, it could save your life. In addition, compass apps also often indicate the time of sunrise and sunset. Handy for Ramadan, for example.
If you need to calibrate your compass app with the magnetometer in your device, holding it up and moving it in a figure eight helps. It is best to do the calibration in a quiet place, where there are not too many other electronics around. They can disrupt the magnetic fields. This applies to both iPhones and Androids : even if the app does not ask for it itself, it is wise to calibrate so that the location is read as accurately as possible.