Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    PySense nonsense altitude readings

    Scheduled Pinned Locked Moved Expansion Board
    lopypysensemodules
    7 Posts 5 Posters 1.7k Views 5 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • philwilkinsonP Offline
      philwilkinson
      last edited by seb

      Re: Implausible pysense pressure readings

      I am getting silly readings from the MPL3115A2 sensor on a PySense using a LoPy 1.0.

       MicroPython v1.8.6-849-055728a on 2018-02-13; LoPy with ESP32
      Type "help()" for more information.
      >>> 
      >>> from pysense import Pysense
      >>> from MPL3115A2 import MPL3115A2, ALTITUDE
      >>> py = Pysense()
      >>> mp = MPL3115A2(py, mode=ALTITUDE)
      >>> import utime
      >>> for i in range(10):
      ...     print('MPL3115A2 altitude is: ' + str(mp.altitude()))
      ...     utime.sleep(60)
      ...     
      ...     
      ... 
      MPL3115A2 altitude is: -5.4375
      MPL3115A2 altitude is: -4.6875
      MPL3115A2 altitude is: -5.75
      

      All firmware is upto date
      Any ideas what the problem is? Has anyone else encountered similar problems (I note that other false readings came after switching between Pressure and Altitude modes, however this is not case in my code.

      1 Reply Last reply Reply Quote 0
      • sebS Offline
        seb
        last edited by

        Im guessing the location you are in is not -5m below sea level?

        1 Reply Last reply Reply Quote 0
        • philwilkinsonP Offline
          philwilkinson
          last edited by

          No, not many places are! It should be something like +10 or +20 m.
          I note other users on the forum have had problems with negative altitudes before. However their problems were related to switching between pressure and altitude modes. In this case I have only selected altitude.

          1 Reply Last reply Reply Quote 0
          • catalinC Offline
            catalin
            last edited by

            The altitude comes from the current pressure value and the pressure at sea-level. I mean, once the sky becomes cloudy, the altitude will seem to vary some 300meters (in a few minutes).
            The sensor altitude value should be used differential. If now it shows -5m, and it you're at +10m, then it's a +15m offset that has to be considered.
            The MPL3115A2.py sensor has some registers for writing the sea-level pressure (offset correction), but this is not implemented.
            You could look into datasheet for better explanations: https://www.nxp.com/docs/en/data-sheet/MPL3115A2.pdf

            Catalin,

            Have you checked out our docs for the answer? (Now with an easy search function) https://docs.pycom.io
            Check out our newly revamped device management platform, Pybytes! https://pybytes.pycom.io/

            J 1 Reply Last reply Reply Quote 1
            • J Offline
              jcaron
              last edited by

              For those not aware, this is how aircraft handle the same issue: https://en.wikipedia.org/wiki/QNH

              Atmospheric pressure varies with altitude and with the weather. At the same exact location, varying pressure is correlated with the weather: high pressure means sunny, low pressure cloudy and stormy, as can be seen in weather forecasts.

              If on the other hand you want to know the altitude, you need to have a reference pressure, usually the pressure at sea level (QNH). If the current pressure is equal to the pressure at sea level, you are at altitude 0. Lower pressures mean higher altitudes, and vice versa.

              L 1 Reply Last reply Reply Quote 2
              • L Offline
                livius @jcaron
                last edited by

                @jcaron
                Because of this, many libs have parameter to set base presure
                and it is taken in calculation

                think about people first, then computers

                1 Reply Last reply Reply Quote 0
                • J Offline
                  jcaron @catalin
                  last edited by jcaron

                  @catalin said in PySense nonsense altitude readings:

                  You could look into datasheet for better explanations: https://www.nxp.com/docs/en/data-sheet/MPL3115A2.pdf

                  Yet another data sheet with complete non-sense... It's saying you should use OFF_H, when really the registers to use are BAR_IN_MSB/BAR_IN_LSB.

                  @seb or @catalin, it would probably be a good idea to add a function in PL3115A2.py to set this value.

                  self.i2c.writeto_mem(MPL3115_I2CADDR, MPL3115_BAR_IN_MSB, bytes([int(qnh*100/2) >> 8, int(qnh*100/2) & 255]))
                  

                  Note that even with this, one should not expect a very precise altitude indication, it can vary several meters up or down. If you want a more precise altitude (and independence from the weather), you probably need to use a GPS.

                  1 Reply Last reply Reply Quote 0

                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                  With your input, this post could be even better 💗

                  Register Login
                  • 1 / 1
                  • First post
                    Last post

                  Pycom on Twitter

                  Pycom