5

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

Kasami
  • 101
  • 1
  • 5

2 Answers2

5

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

Kasami
  • 101
  • 1
  • 5
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

Nick
  • 774
  • 4
  • 16