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.2.tar.gz (9.6 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.2-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pybmx-0.2.2.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.34+rpt-rpi-2712

File hashes

Hashes for pybmx-0.2.2.tar.gz
Algorithm Hash digest
SHA256 7cb37416646d79fa5eebc2f27239b45c6f61decc0d69b86423bc7dfb98f0fc57
MD5 35ae6e9725d9f3ae7fd556913c4ac5ae
BLAKE2b-256 94596790652abdbdbf2ed8939a2b458c05a928949b1cf31a266b307282268222

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pybmx-0.2.2-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.34+rpt-rpi-2712

File hashes

Hashes for pybmx-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 82c874af6cadbc852bdd182a13c9555bb3207aedbfdc207ab1902fba9700e280
MD5 ab3534899ab5f6f8f3dae32258ca3a70
BLAKE2b-256 b7a640475c67e035f6c504440307c9b8d84818309676e98c782ce278f3ff01bb

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