Hello, I did this because I noticed that the altitude of GPS is not stable. GPS coordinates are correct however.

They remain well within a radius of ten meters around the real point. But the altitude is completely crazy, it depends on the day, and even the moment of day. This is related to the position of satellites, I am in Europe, Is this the problem?.But, it's may be a problem for the stabilization of our plane in altitude. And increasingly it is not very accurate.

And with two I2C devices it works, cool.

What do you think of this approach?

E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones


  • Developer
    Great finally someone else is waking up on this matter :)

    I have been trying to say many times that do not trust on your GPS altitude. It changes a lot, constantly and sometimes really quick. Especially if US military makes it jump :P

    Here is one of those many pics that I have send already to here. Altitude graph is logged with uBlox u-Console. This is just one random hour that I collected data on my area here in Bangkok. During logging this data my antenna was on balcony on 10th floor totally motionless. And i had 3D fix all the time. During this logged time altitude jumped from 30m to 80meters above sea level.

    So be carefull and do not trust too much on altitude readings. Barometric is almost only way to measure reliable altitude. At least it does not jump 100 meters in 3 mins like GPS do.

    At our office we have 10 GPS devices constantly logging coordinates and altitude for calibration and other purposes (company produces vehicle tracking devices etc..). Data that is logged looks sometimes really "scary". :)

    Yves is your SCP getting hot?? I soldered mine about same way like yours and it get's really hot also it jam's my i2c bus so it might be dead or something. Need to debug more.. (i wonder if Jordi has warranty for those, it's never been used before ;) )

  • *throw
  • Hi againYves,
    You say you have modified the code to make use of the magnometer and the barometer you've installed in parallel on the I2C port.

    But in this part of the IMU documentation:
    It says that:
    /* Support for optional magnetometer (1 enabled, 0 dissabled) */
    #define USE_MAGNETOMETER 0 // use 1 if you want to make yaw gyro drift corrections using the optional magnetometer

    /* Support for optional barometer (1 enabled, 0 dissabled) */
    #define USE_BAROMETER 0 // use 1 if you want to get altitude using the optional absolute pressure sensor
    #define ALT_MIX 50 // For binary messages: GPS or barometric altitude.

    This seems to imply the default software already has support....why then did you need to make changes to the code?... different ports being used?....both being used on same port?

    Perhaps Doug or Jose might be able to through some light on this too.

    Best wishes,

  • apologies, I didn't see the rest of this thread. Have just visited your site.
  • Heya Yves, Can you give a pin to pin connection diagram of the above please? Looks like you have both the magnometer and the barometer plugged into the same four pins on the arduimu? I have the 6DOF v2 and those pins are labelled GND, 3.3V, SDA, and SCL in that order.....It looks like you have the magnometer and the barometer in parallel with those pins (as I mentioned above)...do I have this right?
    In the code you posted above have you implemented a comparison between the gps altitude and the barometer and the same for the magnometer and the gps heading data.....or have you totally eliminated the use of gps heading and gps altitude?
  • Ive used higher end L1 GPS, specifically some hemisphere crescent units and over an 8 to 10 min helicopter flight the altitude was +/-3M (IE hovering at 3m above the ground it never hit the ground.) These were 10Hz units. there was defiantly a 1 m bob that came and went, but not to bad. This was in an absolutely perfect GPS environment, large open field no buildings within 5 miles.(Our rocket test area out in the desert)

    I've just ordered a 10Hz novatel OEMSTAR and I will evaluate that in the near future.

  • Oh yes, it is already on my site. on this page.
    It is in French of course.
    Keep me posted if you find something. Thank you.
  • Yes, I noticed I had too. I also corrected, simplified a few other points and made a better integration in the code. I'll post it tonight, at least I hope.
    It seems to work fine now.
    Thank you
  • Hello Yves,
    Is the baro alt output backwards ?
    If I lift the baro sensor up, the alt goes down and visa versa.
    Also, this line of code I changed because I am at 2000m in the mountains.

    // Variable to track the Altitude estimate
    long g_i32Altitude;

    // Function to initialise the starting altitude where this is known in m.
    void init_alt(int i16Alt)
    g_i32Altitude = 2000; //(long)i16Alt * 1000L; <<<<<<<<<<<<<< I changed >>>>>>>>>>>>>

    Maybe I goofed up ?

  • Hi,

    unfortunately I don't have systematical data on this, but what I experienced with GPS altitude is:
    - Sparkfun GPS logger (discontinued); altitude is always off, of at least 60m from home position (but it's only a logger)
    - EM406; I experienced during two identical autonomous flights on the same day more than 100m off (I have data on video from Remzibi GPS, that seems to be more accurate, but anyway another source of mistakes)
    - Ublox; I already watched on Ardustation telemetry altitude going off by more than 100-150m during a flight and landing with that amount (manually of coarse ;D).

    I agree: GPS altitude is a thrill, especially flying between mountains and when the plane is banking or pitching.

    Best regards,

This reply was deleted.