bme68x
bme68x is a pure-Rust, no_std, allocation-free driver for Bosch BME680 and
BME688 environmental gas sensors. It uses embedded-hal 1.0 and
embedded-hal-async 1.0, so the same sensor code can run on STM32, ESP32, nRF,
RP2040, Linux adapters, and other supported platforms.
This is an unofficial, community-maintained project. It is not affiliated with or endorsed by Bosch Sensortec.
The compatibility target is Bosch Sensortec's
BME68x_SensorAPI v4.4.8.
Supported functionality
- I2C addresses
0x76and0x77 - I2C and shared-bus-safe
SpiDevicetransports - blocking and async APIs
- BME680 low-gas and BME688 high-gas variants
- forced, sequential, and parallel modes
- temperature, pressure, humidity, and gas-resistance compensation
- one-step and 1–10 step gas-heater profiles
- measurement status, profile index, measurement index, and heater metadata
- exact measurement/heater-duration encodings
- Bosch-style live physical self-test
- raw register access and release of owned bus/delay objects
The default blocking feature can be disabled. Enable async for the
embedded-hal-async frontend:
[]
= { = "0.1", = false, = ["async"] }
Enable float to expose bme68x::float, which reproduces Bosch's
single-precision BME68X_USE_FPU compensation path. This feature is
independent of the blocking/async transport choice and does not add a math
library dependency.
Blocking example
use Bme68x;
use ;
use ;
let interface = new;
let mut sensor = new?;
let configuration = Configuration ;
let heater = Forced ;
sensor.set_configuration?;
sensor.set_heater_configuration?;
sensor.set_operation_mode?;
let conversion_us = measurement_duration_us + 100_000;
// Wait `conversion_us` with your platform timer, then read the field.
let fields = sensor.measurements?;
if let Some = fields.as_slice.first
The async frontend has the same shape under bme68x::asynch; its bus calls and
delays are awaited.
Output units
The primary data path preserves Bosch's fixed-point output exactly:
| Value | Type | Unit |
|---|---|---|
| Temperature | i16 |
0.01 °C |
| Pressure | u32 |
Pa |
| Relative humidity | u32 |
0.001 %RH |
| Gas resistance | u32 |
Ω |
Convenience accessors convert these values to f32 without changing the
canonical stored values. With the optional float feature,
FloatCalibrationData and FloatMeasurement provide Bosch's native FPU-path
units: °C, Pa, %RH, and Ω as f32. Every normal Measurement
also exposes its decoded raw ADC field, so the same sample can be passed to
bme68x::float::compensate without another sensor read.
Gas fingerprints and fire detection
Bosch's open SensorAPI returns compensated gas resistance and programmable heater-scan data. It does not return an IAQ score, smoke label, or trained gas fingerprint. Bosch BSEC and its trained classifiers are separate, closed-source software.
An open wildfire classifier can be built above this crate by recording labeled multi-temperature heater profiles and training/validating a separate model. That model needs field data covering humidity, temperature, sensor aging, contamination, seasons, and non-fire interferents. A BME688 alone must not be treated as a certified life-safety detector; Bosch's datasheet excludes use in safety-critical systems.
Reference testing
Bosch v4.4.8 publishes no unit tests, fixtures, golden vectors, or CI suite. This repository therefore pins the unmodified C release as a host-only differential oracle. It is never linked into target firmware or the published crate.
The fixed-point oracle covers calibration parsing, one-hot and seeded
calibration images, 20-bit T/P samples, 16-bit humidity samples, every gas ADC
value across all 16 ranges and both variants, every u16 duration encoding,
every heater target, and every valid oversampling/mode timing combination.
The independent FPU oracle compares exact f32 bit patterns for temperature,
pressure, humidity, and both gas variants, plus every heater target.
MSRV and licensing
The minimum supported Rust version is 1.75 and the crate uses Rust edition
2021. The project is BSD-3-Clause. See LICENSE and NOTICE.md for Bosch
attribution and the pinned reference revision.