Simple test

Ensure your device works with this simple test.

examples/lps35hw_simpletest.py
 1# SPDX-FileCopyrightText: 2019 Bryan Siepert, written for Adafruit Industries
 2#
 3# SPDX-License-Identifier: Unlicense
 4import time
 5
 6import board
 7
 8import adafruit_lps35hw
 9
10i2c = board.I2C()  # uses board.SCL and board.SDA
11# i2c = board.STEMMA_I2C()  # For using the built-in STEMMA QT connector on a microcontroller
12lps = adafruit_lps35hw.LPS35HW(i2c)
13
14while True:
15    print(f"Pressure: {lps.pressure:.2f} hPa")
16    print(f"Temperature: {lps.temperature:.2f} C")
17    print("")
18    time.sleep(1)

Relative Pressure

Set the current pressure as zero hPa and make measurements relative to that pressure, even negative

examples/lps35hw_relative.py
 1# SPDX-FileCopyrightText: 2019 Bryan Siepert, written for Adafruit Industries
 2#
 3# SPDX-License-Identifier: Unlicense
 4import time
 5
 6import board
 7
 8import adafruit_lps35hw
 9
10i2c = board.I2C()  # uses board.SCL and board.SDA
11# i2c = board.STEMMA_I2C()  # For using the built-in STEMMA QT connector on a microcontroller
12lps = adafruit_lps35hw.LPS35HW(i2c)
13
14# set the current pressure as zero hPa and make measurements
15# relative to that pressure, even negative!
16lps.zero_pressure()
17while True:
18    print(f"Pressure: {lps.pressure:.2f} hPa")
19    print("")
20    time.sleep(0.5)

Threshold Setting

Setting the pressure threshold to act as a trigger

examples/lps35hw_high_threshold.py
 1# SPDX-FileCopyrightText: 2019 Bryan Siepert, written for Adafruit Industries
 2#
 3# SPDX-License-Identifier: Unlicense
 4import time
 5
 6import board
 7
 8import adafruit_lps35hw
 9
10i2c = board.I2C()  # uses board.SCL and board.SDA
11# i2c = board.STEMMA_I2C()  # For using the built-in STEMMA QT connector on a microcontroller
12lps = adafruit_lps35hw.LPS35HW(i2c)
13
14# You may need to adjust the threshold to something closer
15# to the current pressure where the sensor is
16lps.pressure_threshold = 1030
17
18lps.high_threshold_enabled = True
19
20while True:
21    print(f"Pressure: {lps.pressure:.2f} hPa")
22    print(f"Threshhold exceeded: {lps.high_threshold_exceeded}")
23    print("")
24    time.sleep(1)

Using Filter

Using the filter parameter to filter out high-frequency noise

examples/lps35hw_filter.py
 1# SPDX-FileCopyrightText: 2019 Bryan Siepert, written for Adafruit Industries
 2#
 3# SPDX-License-Identifier: Unlicense
 4import time
 5
 6import board
 7
 8import adafruit_lps35hw
 9
10i2c = board.I2C()  # uses board.SCL and board.SDA
11# i2c = board.STEMMA_I2C()  # For using the built-in STEMMA QT connector on a microcontroller
12lps = adafruit_lps35hw.LPS35HW(i2c)
13
14lps.low_pass_enabled = True
15while True:
16    print(f"Pressure: {lps.pressure:.2f} hPa")
17    print("")
18    time.sleep(0.125)

Data Rate

Data rate example

examples/lps35hw_data_rate.py
 1# SPDX-FileCopyrightText: 2019 Bryan Siepert, written for Adafruit Industries
 2#
 3# SPDX-License-Identifier: Unlicense
 4import time
 5
 6import board
 7
 8from adafruit_lps35hw import LPS35HW, DataRate
 9
10i2c = board.I2C()  # uses board.SCL and board.SDA
11# i2c = board.STEMMA_I2C()  # For using the built-in STEMMA QT connector on a microcontroller
12lps = LPS35HW(i2c)
13
14lps.data_rate = DataRate.ONE_SHOT
15lps.take_measurement()
16
17
18while True:
19    print(f"Pressure: {lps.pressure:.2f} hPa")
20    print("")
21    time.sleep(1)
22    print(f"Pressure: {lps.pressure:.2f} hPa")
23    print("")
24    time.sleep(1)
25    print(f"Pressure: {lps.pressure:.2f} hPa")
26    print("")
27    time.sleep(1)
28
29    # take another measurement
30    lps.take_measurement()
31
32    print(f"New Pressure: {lps.pressure:.2f} hPa")
33    print("")
34    time.sleep(1)