iPhone 5s is a giant house of motion sensors. You have the gyroscope, motion sensing accelerometer, magnetometer etc all built into the tiny compact frame of the iPhone 5s. However, given the very nature of sensors, they are bound to go awry especially in the presence of other interferences such as magnetic fields produced by other devices nearby or environmental factors. Also, the possibility that a sensor could be inaccurately calibrated by default is always present. While Apple does ensure things are working perfectly well out of the box, in case you are experiencing troubles with apps which use gyro or compass giving less than accurate results, you can re-calibrate the compass which in turn actually engages with the Core Motion Framework of the device allowing you to calibrate all the motion sensors in one go.
While this may sound extremely complicated to start of with, the jist of the whole thing is that you need to recalibrate the compass of your iPhone 5s in case you are facing issues with the calibration of sensor on your device. To do so, is far more simpler than the theory behind the whole process, simply follow the steps below and you will be able to re-calibrate the motion sensors on your iPhone 5s.
Make sure you turn all the applications off, a fresh restart would help. All apps that use a compass must definitely be shut.
Open the Compass app on your iPhone 5s.
The moment you turn the app on, it would ask you to be granted permission to access your location, which you must, and then would ask you to calibrate the compass by rotating your iPhone in a circle.
Once you have rotated the phone in an entire circle the path will be traced and you will be taken to the compass app which would hopefully give you more accurate results.
You can check with other apps which record your motion and they would definitely be able to give you more accurate results. You can repeat the exercise by simply turning all the apps, including the compass app off and firing it up again to calibrate the device correctly.