Skip to main content

A typed, register-accurate Python driver for the Bosch BME688 environmental sensor.

Project description

BME688

bme688 is a typed, register-accurate Python driver for the Bosch BME688 environmental sensor.

It provides temperature, pressure, and humidity readings using a clean, explicit register model built on top of typed-registers.

The goal is to make working with the sensor:

  • transparent (registers are first-class)
  • typed (dataclasses, no raw byte juggling)
  • predictable (no hidden state or magic)

Features

  • ✅ Typed register definitions (dataclasses)

  • ✅ Accurate Bosch compensation algorithms

  • ✅ Temperature, pressure, and humidity readings

  • ✅ Forced-mode measurement with polling

  • ✅ Clean separation of:

    • register layer
    • device behavior
    • compensation math
  • ✅ CLI for quick testing

Installation

pip install bme688[i2c,cli]

Requirements

  • Python ≥ 3.11
  • I²C enabled (e.g. Raspberry Pi)
  • smbus2

Quick Start

from smbus2 import SMBus
from typed_registers import SMBusRegisterBus
from bme688 import BME688

bus = SMBusRegisterBus(SMBus(1))
sensor = BME688(bus)

sensor.initialize()

reading = sensor.read()

print(reading)

Example output:

Reading(
    temperature_c=23.46,
    pressure_pa=101021.0,
    humidity_rh=41.46
)

CLI Usage

Initialize the device:

bme688 init

Read sensor values:

bme688 read

Example:

Temperature: 23.46 °C
Pressure:    101021.00 Pa
Humidity:    41.46 %RH

Dump raw register state:

bme688 dump

Architecture

The driver is intentionally structured in layers:

Device API
    ↓
Compensation (Bosch algorithms)
    ↓
Typed Registers
    ↓
typed-registers
    ↓
Bus (I²C / SMBus / etc.)

Registers

Each hardware register is modeled as a typed dataclass:

REG_CTRL_MEAS(osrs_t=1, osrs_p=1, mode=0)

Multi-byte registers use structured decoding:

REG_FIELD_DATA(
    new_data=True,
    temperature_adc=...,
    pressure_adc=...,
    humidity_adc=...
)

Design Philosophy

This driver follows a simple rule:

The register map is the API.

  • No hidden abstractions
  • No implicit conversions
  • No “magic” state

Everything maps directly to the datasheet.

Status

Alpha

  • Temperature, pressure, humidity: ✅ stable
  • Gas resistance: ⚠️ partial (raw values available, full pipeline not implemented)

Development

pip install -e .[dev]
mypy src/

License

MIT License

Author

Joshua B. Bussdieker https://github.com/jbussdieker

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

bme688-0.1.0.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

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

bme688-0.1.0-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bme688-0.1.0.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for bme688-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3cca506f0f10f39c08cdc648844ff326592d7eaaf551260c2801bd9173df1a98
MD5 289489181d79c6497be29650046de377
BLAKE2b-256 d88cb70f18cb893dbbae26ced9e1649909711a512e145b4e5e20355cb00f95a7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bme688-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for bme688-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8c0d8863027c4c60a23a891076a0785c4f1407c758d15f907cb548118759d8d8
MD5 d86806e4d6eacb897fbf4cdee96165bd
BLAKE2b-256 5402bf7e66228d7fe133ac5f219d1273355e7fff3a5ac08bb7ead486b56d40de

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