The internal compass of your iPhone is a very useful tool. Unfortunately, it is very easy for the compass to become unaligned, particularly when indoors. The following are a few solutions to help improve the compass accuracy of your iPhone or iPad device.
Your iPhone contains a Magnetometer that is used by the internal compass. Any interference from a nearby magnetic source may affect the compass readings. Make sure to remove any nearby magnets. Keep in mind iPhone cases and pop sockets often have magnetic parts built in. If your device becomes unaligned due to the magnet then removing the source will help but you may need to restart your device.
One of the calibration methods your compass utilizes includes motion over time, whether you are walking around or pulling your phone out of your pocket. One trick to help re-align the compass is to shake your phone or rotate it in a large figure eight motion. For a small misalignment this will often help fine-tune the accuracy of your compass.
In iOS 13 there is a privacy setting to allow your compass to use location services to help calibrate your devices compass. By default, this setting is disabled. Enabling this feature is highly recommended for good compass accuracy.
Refreshing Location Services can help your device clear any GPS errors from previous readings. Another trick to improve compass accuracy is to simple disable and re-enable Location Services.
When your compass becomes misaligned sometimes the fastest method of realignment is to simple restart your device. This may seem tedious, but it is the quickest and most reliable method for restoring your compass to provide optimal readings.
By default, your device will utilize True North for all compass readings. Depending on the compass reading you are trying to get it may make sense to temporarily disable True North and use Magnetic North for a while.
Hopefully some of these tips help you attain accurate compass readings from your device. If your device continues to have issues, there may be an additional software or hardware problems with the phone itself. Please contact Apple Support for any questions about calibrating your compass or to determine if your device may need repair.