Skip to main content

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.0.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pybmx-0.2.0-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file pybmx-0.2.0.tar.gz.

File metadata

  • Download URL: pybmx-0.2.0.tar.gz
  • Upload date:
  • Size: 9.0 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

Hashes for pybmx-0.2.0.tar.gz
Algorithm Hash digest
SHA256 653d72f01137df24e5d3d67bd08c4f5e42ff1c39b6fdcc70fd0c36dd77d8a628
MD5 9714426cbe9b0955993b9dbd4b3d87df
BLAKE2b-256 af2793fb5f98716805377055d7364a5fc1497a5c29425eec8e37654d691f27c4

See more details on using hashes here.

File details

Details for the file pybmx-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pybmx-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 10.6 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

Hashes for pybmx-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1b3443d50a665d38fa4d88582780708d6852fcca49b63f1a7a8ed26e48add4a6
MD5 250561e559a9f3703430b7344923e48d
BLAKE2b-256 7637397c82ac62e1a212f5c5e7f180c5ad0194202829388073ce42553d0453cc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page