Simple test
Ensure your device works with this simple test.
examples/bmp384_simpletest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 | # SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya
#
# SPDX-License-Identifier: MIT
import time
import board
import bmp384
i2c = board.I2C() # uses board.SCL and board.SDA
bmp = bmp384.BMP384(i2c)
while True:
print(f"Pressure: {bmp.pressure:.2f}hPa")
print()
time.sleep(0.5)
|
Power mode settings
Example showing the Power mode setting
examples/bmp384_power_mode.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 | # SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya
#
# SPDX-License-Identifier: MIT
import time
import board
import bmp384
i2c = board.I2C()
bmp = bmp384.BMP384(i2c)
bmp.power_mode = bmp384.NORMAL_MODE
while True:
for power_mode in bmp384.power_mode_values:
print("Current Power mode setting: ", bmp.power_mode)
for _ in range(10):
print(f"Pressure: {bmp.pressure:.2f}hPa")
print()
time.sleep(0.5)
bmp.power_mode = power_mode
|
Filter coefficients settings
Example showing the Filter coefficients setting
examples/bmp384_filter_coefficients.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 | # SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya
#
# SPDX-License-Identifier: MIT
import time
import board
import bmp384
i2c = board.I2C()
bmp = bmp384.BMP384(i2c)
bmp.filter_coefficients = bmp384.IIR_FILTER_X32
while True:
for filter_coefficients in bmp384.filter_coefficients_values:
print("Current Filter coefficients setting: ", bmp.filter_coefficients)
for _ in range(10):
print(f"Pressure: {bmp.pressure:.2f}hPa")
print()
time.sleep(0.5)
bmp.filter_coefficients = filter_coefficients
|
Pressure oversample settings
Example showing the Pressure oversample setting
examples/bmp384_pressure_oversample.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 | # SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya
#
# SPDX-License-Identifier: MIT
import time
import board
import bmp384
i2c = board.I2C()
bmp = bmp384.BMP384(i2c)
bmp.pressure_oversample = bmp384.OVERSAMPLE_X4
while True:
for pressure_oversample in bmp384.pressure_oversample_values:
print("Current Pressure oversample setting: ", bmp.pressure_oversample)
for _ in range(10):
print(f"Pressure: {bmp.pressure:.2f}hPa")
print()
time.sleep(0.5)
bmp.pressure_oversample = pressure_oversample
|
Temperature oversample settings
Example showing the Temperature oversample setting
examples/bmp384_temperature_oversample.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 | # SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya
#
# SPDX-License-Identifier: MIT
import time
import board
import bmp384
i2c = board.I2C()
bmp = bmp384.BMP384(i2c)
bmp.temperature_oversample = bmp384.OVERSAMPLE_X2
while True:
for temperature_oversample in bmp384.temperature_oversample_values:
print("Current Temperature oversample setting: ", bmp.temperature_oversample)
for _ in range(10):
print("ftemperature:{bmp.temperature:.2f}°C")
print()
time.sleep(0.5)
bmp.temperature_oversample = temperature_oversample
|