Bosch sensor BMP and BME library
Project description
pybmx
This is a Python library for temperature, humidity and air pressure bosch sensor devices like the BME280.
Installation
python -m pip install pybmx
Usage
import time
import pybmx
import smbus2 as smbus
# Create a new BME280 object. The current sensor configuration is
# read from the sensor and can be printed.
bus = smbus.SMBus(1)
bme = pybmx.Bme280(bus)
bme.info()
# Configure the BME280 sensor. To enable all sensor functions, the
# oversampling must be activated.
bme.temperature_oversampling = pybmx.Bme280Oversampling.OVERSAMPLING_X1
bme.humidity_oversampling = pybmx.Bme280Oversampling.OVERSAMPLING_X1
bme.pressure_oversampling = pybmx.Bme280Oversampling.OVERSAMPLING_X1
bme.duration = pybmx.Bme280Duration.DURATION_10
# After the configuration, the sensor must be updated to apply the
# new settings.
bme.update()
bme.info()
try:
while True:
# You can read the sensor data with the measure() method. The
# data contains the temperature, humidity and pressure values.
datapoint = bme.measure()
print("-" * 20)
print(f"timestamp: {datapoint.timestamp}")
print(f"temperature: {datapoint.temperature:.3f} °C")
print(f"humidity: {datapoint.humidity:.3f} %rH")
print(f"pressure: {datapoint.pressure:.3f} hPa")
time.sleep(5.0)
except KeyboardInterrupt:
pass
finally:
bus.close()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pybmx-0.2.1.tar.gz
(9.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
pybmx-0.2.1-py3-none-any.whl
(11.4 kB
view details)
File details
Details for the file pybmx-0.2.1.tar.gz.
File metadata
- Download URL: pybmx-0.2.1.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.25.5 CPython/3.11.2 Linux/6.12.20+rpt-rpi-2712
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51acbc3209259ae847453902f1b0ace99aaea8e52f76deafff61c9c8f4f78bd6
|
|
| MD5 |
5b68aa813cd8954cff1370efe28e35eb
|
|
| BLAKE2b-256 |
afeb759827780af369d751912dabfc87f7e112aa9a0b85044b5476c7e65b43bb
|
File details
Details for the file pybmx-0.2.1-py3-none-any.whl.
File metadata
- Download URL: pybmx-0.2.1-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.25.5 CPython/3.11.2 Linux/6.12.20+rpt-rpi-2712
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77ed1b32ffc0fd809edf82038d5bf0daf71907e293021ebdf58f487fd841bfd0
|
|
| MD5 |
abd84f868cb1f02840b4725f5aaaf757
|
|
| BLAKE2b-256 |
9389478abb9b7f32b1dd1a031451f8af00129d28789890dbdaa1495556dcc06d
|