Implausible pysense pressure readings

  • Using the MPL3115A2 on the PySense, I get sensible altitude readings:

    >>> mpa = MPL3115A2(sensors, mode=ALTITUDE)
    >>> mpa.altitude()
    1493.75 # ~4900ft, which is reasonable for where I live

    but very unreasonable pressure:

    >>> mpp = MPL3115A2(sensors, mode=PRESSURE)
    >>> mpp.pressure()
    5969.5 # 6000Pa = 29km, my breathing should be a bit labored!

    Any thoughts? I’ve been comparing the pysense library code to the data sheet for the MPL3115A2, but I don’t see anything obviously wrong.

    Thanks in advance,

  • @catalin - thanks for the quick response. That makes sense, and after instantiating just one instance of MPL3115A2, I’m getting a pressure around 85000 Pa, which is still a bit low (~25 inches of mercury vs 30 according to the national weather service), but might be explained by an unset sea level reference.


  • Hi @tshead,

    I can't reproduce exactly your scenario, but this is what I think it happens: you see the value 1493 is 4 times smaller than 5969, so the pressure sensor is stuck in altitude mode. Because the pressure and altitude numeric values are stored on the same registers, but the numeric function has a scale of 1:4 between them.
    If I try to instantiate the class MPL3115A2 twice, then I will have a problem; there is only a single sensor. Most likely, the has to be modified to be "static"(as in Java/C++) or to always reset sensor in the right way: Altimeter or Pressure.

    >>> mpp = MPL3115A2(py,mode=PRESSURE)
    >>> mpa = MPL3115A2(py,mode=ALTITUDE) # sensor is set in Altitude mode
    >>> print("Altitude: " +  str(mpa.altitude()))
    Altitude: 62.875
    >>> print("Pressure: " +  str(mpp.pressure())) # careful, sensor is still in Altitude mode 
    Pressure: 248.0


Pycom on Twitter