Are you using an iPad case that contains magnets of any kind? For example, a case with a screen cover that operates the auto-lock function? If so, this can seriously affect the calibration of the iPad fluxgate compass.
If used extensively indoors, the compass can lose its calibration. As an example, one model of iPad Pro that I regularly use for testing often loses compass calibration - sometimes presenting a reading as much as 90° from true.
Recalibration of the compass can help. Rather than list the steps here, this external link might be helpful with the procedure to recalibrate the iPad compass:
https://www.titanhst.com/improving-compass-accuracy-on-ios-devices/
In addition to the information within the link, you may find that several full rotations of the iPad in each of its three axis’ (X, Y and Z) will help with recalibration.