Expand description
Bosch BME280 temperature, pressure, and humidity sensor.
The BME280 ships raw, uncompensated readings plus a block of per-chip calibration coefficients; the real measurement only appears after running those raw values through Bosch’s compensation formulas. Those formulas are the classic place a from-memory port goes subtly wrong, so the integer arithmetic here is ported from Bosch’s published reference code, and the tests cross-check it against the reference floating-point form and the datasheet’s worked temperature example.
A caller reads the calibration registers once with Calibration::from_registers,
then reads the data registers each cycle into a RawMeasurement and calls
Calibration::compensate. The control registers (CtrlHum, CtrlMeas,
Config) and the measurement-time formula are here too, and the Bme280
driver (the embedded-hal feature) runs the whole sequence over an I2C or SPI bus.
Modules§
- register
- The BME280 register addresses used to read calibration and measurements.
- sim
- A BME280 that is not there.
Structs§
- Bme280
- A BME280 on an I2C or SPI bus, measuring on demand in forced mode.
- Calibration
- The per-chip calibration coefficients read from the sensor’s calibration registers.
- Config
- The configuration register (0xF5,
config). - CtrlHum
- The humidity control register (0xF2,
ctrl_hum). - Ctrl
Meas - The measurement control register (0xF4,
ctrl_meas). - Measurement
- A compensated BME280 measurement.
- RawMeasurement
- The raw, uncompensated readings from the BME280 data registers.
Enums§
- Filter
- The IIR filter coefficient, the
filter[2:0]field. - Mode
- The power mode selected by the
mode[1:0]field. - Oversampling
- An oversampling setting for one of the three measurements.
- Standby
- The inactive period between measurements in normal mode, the
t_sb[2:0]field.
Constants§
- CALIB_
HUMIDITY_ LEN - The number of bytes in the humidity calibration block.
- CALIB_
TEMP_ PRESS_ LEN - The number of bytes in the temperature and pressure calibration block.
- CHIP_ID
- The value the chip-id register (0xD0) returns for a BME280.
- DATA_
LEN - The number of bytes in the burst-read data block.
- I2C_
ADDRESS_ PRIMARY - The I2C address with the SDO pin tied low.
- I2C_
ADDRESS_ SECONDARY - The I2C address with the SDO pin tied high.
- RESET_
WORD - The soft-reset word: writing it to
register::RESETruns the power-on sequence. - SKIPPED_
HUMIDITY - The value a skipped humidity measurement leaves in its registers.
- SKIPPED_
OUTPUT - The value a skipped temperature or pressure measurement leaves in its registers.
- STARTUP_
MICROS - The start-up time from power-on or reset until the part accepts a transfer, in microseconds.
- STATUS_
POLLS - How many times the status register is polled, 1 ms apart, before a conversion or a reset is called overdue.
Functions§
- image_
updating - Reads the
im_updateflag of a status register value. - max_
measurement_ micros - The longest one measurement cycle can take, in microseconds.
- measuring
- Reads the
measuringflag of a status register value. - typical_
measurement_ micros - The typical time one measurement cycle takes, in microseconds.