Skip to main content

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

Metadata

Release files for bme688 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bme688 0.1.0
File Size Uploaded
bme688-0.1.0.tar.gz 12.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bme688 0.1.0
File Interpreter ABI Platform
bme688-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 24.5 kB

Release files / bme688-0.1.0.tar.gz

Download URL bme688-0.1.0.tar.gz
Size 12.8 kB
Tags Source
SHA-256 checksum
How to use checksums
3cca506f0f10f39c08cdc648844ff326592d7eaaf551260c2801bd9173df1a98
BLAKE2b-256 checksum
How to use checksums
d88cb70f18cb893dbbae26ced9e1649909711a512e145b4e5e20355cb00f95a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / bme688-0.1.0-py3-none-any.whl

Download URL bme688-0.1.0-py3-none-any.whl
Size 11.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8c0d8863027c4c60a23a891076a0785c4f1407c758d15f907cb548118759d8d8
BLAKE2b-256 checksum
How to use checksums
5402bf7e66228d7fe133ac5f219d1273355e7fff3a5ac08bb7ead486b56d40de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.2.0 CPython/3.12.13

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page