PiicoDev Magnetometer QMC6310 (CE07937)

This is a placeholder topic for “PiicoDev Magnetometer QMC6310” comments.

Measures invisible magnetic fields - use as a compass or to detect nearby magnets.

Read more

I’d like to use this module in an arduino-based project. Would this be possible - would I need to look at the micropython libraries to figure out the I2C interface for this device? I’d like to calibrate and then get a usable compass heading.

Hey Colin,

Getting a compass heading would be an awesome use of this board, it definitely has the capability to do so.

The issue you are going to run into is using it with an Arduino project, as PiicoDev products aren’t currently supported on Arduino. I am sure you can get the compass set up done using MicroPython, otherwise you may have to find arduino libraries for the chip used on the magnetometer and tweak it to use it for an Arduino based project.


Hey Core folk!

Been trying for > 2 hours to calibrate this on a raspberry pi4 - following Michael’s awesome guide - but no matter what I try, or how many times I try, or how slow I go… I can’t get it to calibrate a full 360 rotation where it’s not mangled for at least 90degs of it.

I’m also having to rotate it 3 or more times, instead of the single rotation Michael was able to do.

I’m laying it flat on a table and rotating it like Michael did… only difference is I don’t have long STEMMA cables, so maybe it’s too close to the rPI - but There’s not much I can do about that.

Any ideas?


1 Like

Hi Seon,

Sorry to hear that sensor isn’t calibrating as nicely for you.
Can you post a quick photo of your setup? Just so we can give everything a look over and make sure everything looks normal with the physical setup of the device.

Were you just using the PiicoDev example code compass.py to start with? Or have you pulled that calibration routine from our code and are integrating it into your own code?

The cables shouldn’t matter too much provided the distance is short enough that the I2C messages can get through ok. Were there any other devices currently on the same I2C bus connected?

1 Like

Hey Trent,
Just a standard setup using your compass code - nothing else connected on the I2C BUS.

The comment re short cables is that it’s hard to rotate 360 or more as it twists and gets shorter - and it’s close to the rPI.

Cheers :slight_smile: Seon

1 Like

Hi Seon,

Ah that would be a challenging cable to calibrate with. Michael doesn’t make a particular mention of this in his guide but it is best to try and rotate the sensor without it translating as much as possible.
Ideally you want the sensor in the centre of the magnetometer to stay in the same place and only have a rotation on the spot.

One other aspect that might be worth consdering is the environment itself you are in. You mentioned that the calibration is a bit mangled for a 90 degree segment. Is it always the same 90 degree orientation that has the issue, or does it change each calibration?
I.E does it always play up when facing east but otherwise works correctly?

It may also be worth moving your setup if it is reasonably portable and repeating the test, just to see if the issue is consistent if your project moves to another location. If it works normally when moved you may have inadvertently detected a source of magnetic interference while trying to calibrate.

Let me know how you go with those variations to the calibration routine and we’ll look at replicating your setup here with the same length cable, just to see if we get the same result.

1 Like

Hey Trent,
It’s a different area every time… clearly based on my rotation ability… not from interference I don’t think.

Is it possible to share a calibration that you have that works? I don’t care where North is (real or magnetic) I just want to have a 360deg rotation starting for anywhere, so maybe loading a better quality calibration will be fine for my needs.

At worst, I can compare the 2 to get a better idea of what’s mangled in mine.

Thanks :slight_smile: Seon

1 Like

Hi Seon,

Our forum doesn’t like the .cal extension as an attachment because it’s an unknown file type.

I’ve included the contents of my calibration.cal file below so you can see how it compares to your file.


FYI It took me 2 full rotations to get a calibration even using the 500mm PiicoDev cable, so perhaps Michael got lucky during the video when he got his in just one rotation.

I did try the 100mm cable and not having enough space to rotate the magentometer around a fixed point definitely makes it take longer to calibrate, though I didn’t observe any changes in the quality of the output it gave once it had calibrated successfully. I certainly haven’t seen a 90 degree window with mangled results with the unit I’ve tested