Android Compass Accuracy

I am using Input.compass.trueHeading on my Samsung Galaxy 10S and the result is all over the place.
It is not only wildly inaccurate but it also constantly changes without me me rotating the device itself.
I thought that maybe something’s wrong with my device, but when using compass apps from the play store, their accuracy is phenomenal and jittering is minimal to non-existent.
Am I using the function wrong? Is there some kind of algorithm I can use to improve this? Or is this just the limit of what Unity can provide?

if you debug, let’s say the exact values for the compass, you’ll see that is really jittery… all these apps have some way to round values, you have to do the same

EDIT

I’m not sure how you could do that… maybe building some average value taking the last… let’s say… 5 values?

so what you have to do is to build an array and on each update you get…

i’m not sure about the code but this is the algorithm:

you get an update of the compass:

if the array count isn’t 5, then add it to the array.

if the array count is 5, then add the value and shift the array to delete the first element

then go to a for loop and sum all values and divide it by the array count…

hope it helps!