How to add external compass to Flip32

In my last post I’ve showed how to disable internal MHC5883L compass on Flip32+ (10DOF) flight controller board. Now it’s time to fix what we’ve broken last time, and connect external MHC5883L compass with I2C bus.

u-blox NEO-6M with HMC5883L compass

In my case I used very popular setup: u-blox NEO-6M GPS module with integrated MHC5883L compass. So you have both GPS and magnetometer in one case. Pretty nice. I’ve described how to connect NEO-6M GPS few weeks ago, so that part should be covered. The only new thing is compass itself. And hardware setup for it is very simple. In addition to GND and +5V lines you only have to connect SDA and SCL lines to bottom line of connectors right to USB port on Flip32. SDA to SDA, SCL to SCL. In case of I2C we do not have swap lines or do any other kinds of voodoo.

I2C bus on Flip32

And that is all. Simple, right? After booting the board MAG sensor should be enabled and compass should be working.

External compass un and running

The only thing that is left is calibration and some additional magic. Let’s begin with magic. Circuit orientation on external board can be different than internal’s. And Cleanflight will have absolutely no idea about that if we will not tell it about that. In case of Flip32, X axis of HMC5883L covers with it’s roll axis. Compass inside my GPS module is not only rotated by 90 degrees, but also flipped upside-down. So, not only north was pointing east. East was pointing west as well. Rotated and mirrored at the same time. Luckily, MultiWii, Baseflight and Cleanflight developers thought about that and the is CLI command that fixes it: align_mag. It can take following values:

0 driver default
 1 CW0_DEG  not rotated or flipped
 2  CW90_DEG  rotated by 90 degrees (Z axis), not flipped (X axis)
 3 CW180_DEG  rotated by 180 degrees (Z axis), not flipped (X axis)
 4  CW270_DEG  rotated by 270 degrees (Z axis), not flipped (X axis)
 5  CW0_DEG_FLIP  rotated by 0 degrees (Z axis), flipped (X axis)
 6  CW90_DEG_FLIP rotated by 90 degrees (Z axis), flipped (X axis)
 7 CW180_DEG_FLIP  rotated by 180 degrees (Z axis), flipped (X axis)
 8 CW270_DEG_FLIP  rotated by 270 degrees (Z axis), flipped (X axis)

In case of Flip32’s original compass it was case 1. No rotation and not flipped. In case of this NEO-6M it was case 8. So, typing in CLI following fixed misalignment.

set align_mag=8

Then standard MAG calibration and done. New compass connected and configured. Hopefully far enough for power cables that will not drift any more.

External HMC5883L will work only in internal, built-in, circuit has been physically disabled. I2C bus does not allow for two devices with the same address to work together! So, either internal, or either external. The is no software solution to disable internal magnetometer! Circuit has to be either removed or SDA line has to be cut. I prefer complete removal.

15 thoughts to “How to add external compass to Flip32”

  1. Hi, did it improve the poshld and other flight modes? With the integrated one I got a lot of toilet bowl effect. Now removed it from flip32 and connecting the gps mag. Thanks.

    1. Yes, it improves PosHold and all GPS assisted modes greatly. Toilet bowling is in 90% cases effect of MAG problems. Usually too much mag. field around it to work correctly

  2. I am now using iNav 1.1, but set align_mag = 8 or set align_mag = CW270_DEG_FLIP does not work. the CLI says: “Invalid value”

    What do I need to type in the CLI?

  3. Yes, I was asking Raul if by changing it to external did it improve the behavior of his quad. Sorry that I was not clear.

    1. My first GPS was a NEO 6M. That didn’t worked that well. After calibrating my compass that’s mounted on the Flip32. The Flip32 still doesn’t know where north is. So I bought a NEO M8N. First I got more satalites, second GPS hold workes instead of getting fly away’s and thirth it know where north is.

      So don’t by the cheapest GPS! I would recommend the NEO M8N.


      1. Raoul –
        M8N’s or better is what i’ve found to be my standard, also. When you say that the quad knows where north is, I’m assuming you used the M8N’s Compass with the Flip?


        1. Yes solderd the compass of the Flip32 and connected the external compass of the M8N via I2C to the Flip32


          1. Thanks for the quick reply, Raoul and thanks to you, very much, Dziku for this post. Looking forward to doing this mod.
            I also bought an M8N that was presented as an I2C GPS, turns out it was a regular M8N GPS (which was good) and it came with a “Crius I2C-GPS Nav Module”. I’ve found some sites that show how to hook this up, and i want to give it a try. I currently have a Data Logger, OSD and S-Bus taking up the 3 UART ports on my SPRacingF3 controller. I’m having to push my GPS to a SoftSerial Port – and although the GPS is getting 3D (haven’t flown it well, yet ’cause of the toilet-bowling), and although it may work, SoftSerial necessitates a compromise in baud rate.
            ME? I want it all!
            thanks again,
            Russ from Coral Springs, Fl, usa

  4. Every time I calibrate the set align_mag I go back to the GUI and the quad doesn’t really follow along. For instance if I turn 90 degrees the picture of the quad keeps spinning. It never seems to point correct north. Am I doing something wrong (yes). What?

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.