Skip to content

bme280

BME280 temperature / humidity / pressure sensor driver.

Layer 3 logical driver — knows nothing about the bus or MCU register layout. Communicates via a [BusHandle] provided at construction.

The BME280 supports both I2C and SPI, but the register addressing convention differs between them: on SPI, bit 7 of the address byte selects read (1) or write (0); on I2C the register address is used unmodified and the direction is carried by the bus’s own start/address phase (already handled below [BusHandle]). The register constants in this file are written in their SPI read form (bit 7 set), matching the BME280 datasheet’s memory map. Because a bus-agnostic [BusHandle] carries no notion of which physical transport underlies it, the caller must say so explicitly via [Transport] at construction time — this driver cannot infer it and will not guess.

Every accessor here either returns a value derived from raw ADC counts run through Bosch’s published compensation formulas, or an explicit [BusError]. There is no code path that manufactures a plausible-looking number: reads before [Bme280::init] has captured calibration data fail closed, and requesting humidity from a chip identified as a BMP280 (which has no humidity sensor) fails closed rather than returning zero or noise.

struct Bme280<'a> { /* private fields */ }

BME280 temperature/humidity/pressure sensor.

enum Transport {
I2c,
Spi,
}

Physical transport the [BusHandle] is wired to.

The BME280’s register addressing convention depends on this: SPI reads require bit 7 of the address byte set and writes require it clear, while I2C uses the address unmodified for both. BusHandle itself carries no transport information, so the driver cannot detect this automatically.

Implements: Clone, Copy, Debug, Eq, PartialEq, StructuralPartialEq

enum Variant {
Bme280,
Bmp280,
}

Which physical part responded to the chip-ID read.

Implements: Clone, Copy, Debug, Eq, PartialEq, StructuralPartialEq