4

I'm building a project based on raspberry pi that relies on fairly accurate compass to be viable. Essentially, if I could know where's North with about 10° of error, I'd be quite happy.

I've bought Sense HAT and even after calibrating it, quite disappointed with the results. If I spin it 3-4 times, results were going absolutely wild. I've set a marker at 360° , but after spinning it couple of times, it became 60°, than 170°, than 280°. It seems like even my phone has higher accuracy in this regard.

I've bought two other magnetometers since, but the result was pretty similar.

Is there a way to get more accurate way of getting compass readings? I'm afraid i might have to pull them from the phone via adb, which sounds like a poor solution.

Appreciate any advice

7
  • 1
    I’ve found digital compasses are not great. I used dual RTK GPS to get an accurate bearing.
    – CoderMike
    Jul 27, 2020 at 19:13
  • 1
    @CoderMike Thanks for the suggestion! I actually do have RTK for GPS, but it doesn't come with compass. Do you calculate it based on direction of movement? I can't seem to come up with a way of doing that if the board is stationary.
    – Kasami
    Jul 27, 2020 at 19:36
  • 1
    The GPS should give you a bearing.
    – CoderMike
    Jul 27, 2020 at 19:53
  • 1
    Neo8M says its heading is 0.3 degree accurate. Is it Ok with you? (2) u-blox.com/sites/default/files/… (3) raspberrypi.stackexchange.com/questions/113544/…. Cheers.
    – tlfong01
    Jul 28, 2020 at 1:53
  • 1
    The Neo8M I am playing with actually has HMC5983 on board, for you to do some real time local bearing adjustments: (4) AliExpress Micro GYGPSV5-NEO M8N NEO-M8N GPS Module HMC5983 Pixhawk - APM US$22 nl.aliexpress.com/item/4000206421398.html, (5) TaoBao GYGPSV5-M8N NEO-M8N GPS APM2.6 HMC5983 - ¥125 item.taobao.com/…. Cheers.
    – tlfong01
    Jul 28, 2020 at 2:03

2 Answers 2

3

It turns out that a lot of the cheaper magnetometers just aren't accurate enough and there isn't that much you can do about that.

I've tried Sense HAT, MPU9250, 6050, QMC, all sharing the same issues, but to a different extent.

When I turned my eye to more specified robotics devices, I've discovered UK-based company "Robot Electronics", which sells compasses among other things.

I've bought CMPS14 from them and it is a very clear winner in accuracy even straight out of the box. It can be connected to Raspberry Pi over I2C and provides extremely accurate results for my purposes.

For anyone wondering technical details of that chip can be found here

1
  • Interesting find, but it should be noted that CMPS14 is also a clear "winner" in terms of price. Apr 9, 2021 at 14:52
2

A magnetometer, otherwise known as a digital compass, is first and foremost a sensor that measures the Earth’s magnetic field in three dimensions. They are also known to be noisy, esp. if they’re anywhere near another magnet typically a monitor, power supply, or similar electronics. Try moving your sensor around and you may see it move because of such. If so move the sensor away from the magnet.

To achieve a stable accurate reading you need to fuse, or combine, the magnetometer reading with another estimate of direction such as an accelerometer or gyroscope which will tell you if you’re changing direction. The fusion is not straightforward. If you’re not worried by maths have a look for details on Kalman filters and Inertial Management Units. There is a lot of Python code you can use, but you still need to have a rough understanding of the math. A Jupyter notebook is available here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.