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

# 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(f"timestamp: {datapoint.timestamp}")
        print(f"temperature: {datapoint.temperature} °C")
        print(f"humidity: {datapoint.humidity} %")
        print(f"pressure: {datapoint.pressure} 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.1.1.tar.gz (8.7 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.1.1-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pybmx-0.1.1.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.22.4 CPython/3.13.2 Windows/11

File hashes

Hashes for pybmx-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c7320919a9563b1bf8108c65fad514fabfeb9b55b4c774eeb127b0b360c85255
MD5 203a459b41771c6b5a21efe747763a61
BLAKE2b-256 5fab7a184564db87d101e98412e098a77966180bd557fde97f403e89152655a5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pybmx-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.22.4 CPython/3.13.2 Windows/11

File hashes

Hashes for pybmx-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1d77d5a409dac4b5738ffe8bd211b7801bb9123b1a078d252ed5fefc16e02aa0
MD5 6c6c649ccac166abc3faea0185ce9618
BLAKE2b-256 cc00afebd0b2da8db20ad5b99bae4bf1b5dc2e409ede1bcc55fc545a6a8eced8

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