> For the complete documentation index, see [llms.txt](https://ruggedboard.gitbook.io/ruggedboard/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ruggedboard.gitbook.io/ruggedboard/tutorial-using-c/lib-mraa-and-upm-sensor-libraries/example-programs/pressure-sensor.md).

# Pressure Sensor

MPL3115A2

Code to interface a Pressure sensor(MPL3115A2)

```
#!/usr/bin/env python

from __future__ import print_function
import time, sys, atexit
from upm import pyupm_mpl3115a2 as MPL3115A2

def main():
    # Instantiate the Infrared-Thermopile Sensor on I2C on bus 1
    mySensor = MPL3115A2.MPL3115A2(2)
    # activate periodic measurements
    mySensor.testSensor();
    #Print out temperature value and config-reg in hex every 0.5 seconds
    while(1):
        print(&quot;Pressure: &quot;+str(mySensor.getPressure(True)))
        print(&quot;Altitude: &quot;+str(mySensor.getAltitude()))

        print(&quot;Sealevel Pressure: &quot;+str(mySensor.getSealevelPressure(True)))
        print(&quot;Temperature: &quot;+str(mySensor.getTemperature(True)))
        time.sleep(2)
if __name__ == &#39;__main__&#39;:
    main()
```

**To run the program,** \
**Step 1: save the file as mpl3115a2.py**\
**Step 2: Run the Program in the board's terminal using** `python3 mpl3115a2.py`
