Simple test
Ensure your device works with this simple test.
examples/lps28_simpletest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14 | # SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya
#
# SPDX-License-Identifier: MIT
import time
import board
import lps28
i2c = board.I2C()
lps = lps28.LPS28(i2c)
while True:
print("Pressure: {:.2f}hPa".format(lps.pressure))
time.sleep(0.5)
|
Data rate settings
Example showing the Data rate setting
examples/lps28_data_rate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 | # SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya
#
# SPDX-License-Identifier: MIT
import time
import board
import lps28
i2c = board.I2C()
lps = lps28.LPS28(i2c)
while True:
for data_rate in lps28.data_rate_values:
print("Current Data rate setting: ", lps.data_rate)
for _ in range(10):
press = lps.pressure
print("Pressure: {:.2f}hPa".format(press))
time.sleep(0.5)
lps.data_rate = data_rate
|
Resolution settings
Example showing the Resolution setting
examples/lps28_resolution.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 | # SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya
#
# SPDX-License-Identifier: MIT
import time
import board
import lps28
i2c = board.I2C()
lps = lps28.LPS28(i2c)
while True:
for resolution in lps28.resolution_values:
print("Current Resolution setting: ", lps.resolution)
for _ in range(10):
press = lps.pressure
print("Pressure: {:.2f}hPa".format(press))
time.sleep(0.5)
lps.resolution = resolution
|
Temperature Example
Example showing how to verify the temperature
examples/lps28_temperature.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14 | # SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya
#
# SPDX-License-Identifier: MIT
import time
import board
import lps28
i2c = board.I2C()
lps = lps28.LPS28(i2c)
while True:
print("Temperature: {:.2f}C".format(lps.temperature))
time.sleep(0.5)
|