MEMS compasses are awful. You only get something vaguely useful if and only if:
- You properly calibrate for soft and hard iron errors - even then there will be errors.
- Don't use magnetic components nearby on the board (ie steel-containing resistors, capacitors
within a cm or two, note most have steel end-caps) - Use away from any ferrous metals (ie outside away from buildings, not in a steel box!) - this applies to all compasses
Also they produce a lot of noise, several degrees worth typically.
Having said they are awful, they are the best you can do in a small package (assuming household
rather than government budget is available).