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.0.tar.gz (8.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.1.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pybmx-0.1.0.tar.gz
  • Upload date:
  • Size: 8.6 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.0.tar.gz
Algorithm Hash digest
SHA256 2ba039dc60ea187b743d98acfc9b4e2b7d54d464e0c25fa9c31c508389f5220e
MD5 ff417d2942d1f10d0391e5240681f7e0
BLAKE2b-256 00849eae9d67b60cee5a2e02754732a64b3b6a52d2671bf9069e30a7238b604b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pybmx-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.4 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 54ff474f9a422752397b047ca5195e40f663bd8ff924f41fe7840412e8d47a41
MD5 898805148849c188e3507cc42d2e5b6a
BLAKE2b-256 944c4bb7ffc8b0af324f10d2303643d860aad2ffcf497e15ee2a63e8f13280cf

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