My compass is not giving accurate readings

I have calibrated the compass but it is still not accurate

My magnetometer is not working, what should I do?

Do I have a faulty compass?


The compass on every micro:bit has slightly different readings by default, and the magnetic environment that they are used in also greatly affects readings - for example, the behaviour of the device with and without the battery pack is completely different!

As a result of this, it's necessary to calibrate the compass in the same environment that you want to use it in, especially adding any accessories that you will be using with the micro:bit, like a battery pack, first.

Please see this article to see how to calibrate the compass

The compass calibration will be stored after you have performed it once, but will be erased every time you re-program the micro:bit over USB.

If you would like to initiate a calibration from your program, you can do it as follows

For Python:

Include the code 


For Javascript Blocks editor powered by Microsoft MakeCode

Include the 'Calibrate Compass' block

Last reviewed 27 July - JA