RegForge

All parts / BME280

BME280 register map

Combined humidity, pressure and temperature sensor — Bosch Sensortec

14 registers I2C, SPI I²C 0x76, 0x77 8-bit reg addresses 62% bit coverage not yet human-verified
I²C address conflict. On its default address(es) this part collides with BMP280 (0x76, 0x77); PCA9685 (0x76, 0x77). You cannot put them on the same bus without changing a strap pin, using an I²C multiplexer, or moving one to a second bus. See the full address map.

Get it as a C header

pip install regforge
regforge gen BME280 --out ./src --driver --tests

Writes bme280_regs.h with every address, mask and shift below, a bus-agnostic driver skeleton, and a file of compile-time assertions that make your compiler check the bit arithmetic. No API key needed — this part ships inside the package.

Not yet human-verified. Transcribed and mechanically validated — no overlapping fields, no out-of-range bits, reset values consistent with their fields — but not yet checked line-by-line against the datasheet. Verifying it is a useful half hour.

Registers

AddrRegisterAccessWidthResetDescription
0xD0CHIP_IDRO80x60Chip identification number. Reads 0x60 on a BME280 (0x58 on a BMP280).
0xE0RESETWO80x00Write 0xB6 to trigger a soft reset. Any other value is ignored. Reads return 0x00.
0xF2CTRL_HUMRW80x00Humidity acquisition options. Changes take effect only after a write to CTRL_MEAS.
0xF3STATUSRO80x00Device status
0xF4CTRL_MEASRW80x00Pressure and temperature acquisition options, and the sensor mode
0xF5CONFIGRW80x00Rate, filter and interface options. Writes are ignored in normal mode.
0xF7PRESS_MSBRO80x80Raw pressure, bits [19:12]
0xF8PRESS_LSBRO80x00Raw pressure, bits [11:4]
0xF9PRESS_XLSBRO80x00Raw pressure, bits [3:0] in bits [7:4]
0xFATEMP_MSBRO80x80Raw temperature, bits [19:12]
0xFBTEMP_LSBRO80x00Raw temperature, bits [11:4]
0xFCTEMP_XLSBRO80x00Raw temperature, bits [3:0] in bits [7:4]
0xFDHUM_MSBRO80x80Raw humidity, bits [15:8]
0xFEHUM_LSBRO80x00Raw humidity, bits [7:0]

Bit layouts

Drawn MSB-first, the way the datasheet draws them. [7:5] means shift 5, width 3, mask 0xE0 — this is the notation that costs people a day when they read it backwards.

CTRL_HUM  @  0xF2  —  1 fields
—7
—6
—5
—4
—3
OSRS_H[2:0]
BitsFieldAccessMaskResetDescription
[2:0]OSRS_HRW0x070x00Oversampling setting for humidity

CTRL_HUM.OSRS_H values

ValueNameMeaning
0x00SKIPPEDMeasurement skipped, output set to 0x80000
0x01X1Oversampling x1
0x02X2Oversampling x2
0x03X4Oversampling x4
0x04X8Oversampling x8
0x05X16Oversampling x16
STATUS  @  0xF3  —  2 fields
—7
—6
—5
—4
MEASURING[3]
—2
—1
IM_UPDATE[0]
BitsFieldAccessMaskResetDescription
[3]MEASURINGRO0x080x00Set while a conversion is running
[0]IM_UPDATERO0x010x00Set while NVM data is being copied to image registers
CTRL_MEAS  @  0xF4  —  3 fields
OSRS_T[7:5]
OSRS_P[4:2]
MODE[1:0]
BitsFieldAccessMaskResetDescription
[7:5]OSRS_TRW0xE00x00Oversampling setting for temperature
[4:2]OSRS_PRW0x1C0x00Oversampling setting for pressure
[1:0]MODERW0x030x00Sensor operating mode

CTRL_MEAS.OSRS_T values

ValueNameMeaning
0x00SKIPPEDMeasurement skipped, output set to 0x80000
0x01X1Oversampling x1
0x02X2Oversampling x2
0x03X4Oversampling x4
0x04X8Oversampling x8
0x05X16Oversampling x16

CTRL_MEAS.OSRS_P values

ValueNameMeaning
0x00SKIPPEDMeasurement skipped, output set to 0x80000
0x01X1Oversampling x1
0x02X2Oversampling x2
0x03X4Oversampling x4
0x04X8Oversampling x8
0x05X16Oversampling x16

CTRL_MEAS.MODE values

ValueNameMeaning
0x00SLEEPNo measurements, minimum power
0x01FORCEDOne measurement, then return to sleep
0x02FORCED_ALTAlternate encoding of forced mode
0x03NORMALCycles between measuring and standby
CONFIG  @  0xF5  —  3 fields
T_SB[7:5]
FILTER[4:2]
—1
SPI3W_EN[0]
BitsFieldAccessMaskResetDescription
[7:5]T_SBRW0xE00x00Inactive duration in normal mode
[4:2]FILTERRW0x1C0x00IIR filter time constant
[0]SPI3W_ENRW0x010x00Enable 3-wire SPI interface

CONFIG.T_SB values

ValueNameMeaning
0x000_5_MS0.5 ms
0x0162_5_MS62.5 ms
0x02125_MS125 ms
0x03250_MS250 ms
0x04500_MS500 ms
0x051000_MS1000 ms
0x0610_MS10 ms -- differs from the BMP280
0x0720_MS20 ms -- differs from the BMP280

CONFIG.FILTER values

ValueNameMeaning
0x00OFFFilter off
0x01COEFF_2Coefficient 2
0x02COEFF_4Coefficient 4
0x03COEFF_8Coefficient 8
0x04COEFF_16Coefficient 16

Generated C header

What regforge gen BME280 writes for CTRL_MEAS:

/* ------------------------------------------------------------------------ */
/* CTRL_MEAS @ 0xF4u  rw  8-bit  reset 0x00u */
/* Pressure and temperature acquisition options, and the sensor mode */
/* ------------------------------------------------------------------------ */

#define BME280_CTRL_MEAS                               0xF4u
#define BME280_CTRL_MEAS_WIDTH                         8u
#define BME280_CTRL_MEAS_RESET                         0x00u

/*   OSRS_T bits [7:5] rw reset 0x00u -- Oversampling setting for temperature */
#define BME280_CTRL_MEAS_OSRS_T_SHIFT                  5u
#define BME280_CTRL_MEAS_OSRS_T_WIDTH                  3u
#define BME280_CTRL_MEAS_OSRS_T_MASK                   0xE0u
#define BME280_CTRL_MEAS_OSRS_T_GET(reg)               (((uint8_t)(reg) & 0xE0u) >> 5u)
#define BME280_CTRL_MEAS_OSRS_T_SET(reg, val)          (((uint8_t)(reg) & (uint8_t)~0xE0u) | (((uint8_t)(val) << 5u) & 0xE0u))
#define BME280_CTRL_MEAS_OSRS_T_SKIPPED                0x00u  /* Measurement skipped, output set to 0x80000 */
#define BME280_CTRL_MEAS_OSRS_T_X1                     0x01u  /* Oversampling x1 */
#define BME280_CTRL_MEAS_OSRS_T_X2                     0x02u  /* Oversampling x2 */
#define BME280_CTRL_MEAS_OSRS_T_X4                     0x03u  /* Oversampling x4 */
#define BME280_CTRL_MEAS_OSRS_T_X8                     0x04u  /* Oversampling x8 */
#define BME280_CTRL_MEAS_OSRS_T_X16                    0x05u  /* Oversampling x16 */

/*   OSRS_P bits [4:2] rw reset 0x00u -- Oversampling setting for pressure */
#define BME280_CTRL_MEAS_OSRS_P_SHIFT                  2u
#define BME280_CTRL_MEAS_OSRS_P_WIDTH                  3u
#define BME280_CTRL_MEAS_OSRS_P_MASK                   0x1Cu
#define BME280_CTRL_MEAS_OSRS_P_GET(reg)               (((uint8_t)(reg) & 0x1Cu) >> 2u)
#define BME280_CTRL_MEAS_OSRS_P_SET(reg, val)          (((uint8_t)(reg) & (uint8_t)~0x1Cu) | (((uint8_t)(val) << 2u) & 0x1Cu))
#define BME280_CTRL_MEAS_OSRS_P_SKIPPED                0x00u  /* Measurement skipped, output set to 0x80000 */
#define BME280_CTRL_MEAS_OSRS_P_X1                     0x01u  /* Oversampling x1 */
#define BME280_CTRL_MEAS_OSRS_P_X2                     0x02u  /* Oversampling x2 */
#define BME280_CTRL_MEAS_OSRS_P_X4                     0x03u  /* Oversampling x4 */
#define BME280_CTRL_MEAS_OSRS_P_X8                     0x04u  /* Oversampling x8 */
#define BME280_CTRL_MEAS_OSRS_P_X16                    0x05u  /* Oversampling x16 */

/*   MODE bits [1:0] rw reset 0x00u -- Sensor operating mode */
#define BME280_CTRL_MEAS_MODE_SHIFT                    0u
#define BME280_CTRL_MEAS_MODE_WIDTH                    2u
#define BME280_CTRL_MEAS_MODE_MASK                     0x03u
#define BME280_CTRL_MEAS_MODE_GET(reg)                 (((uint8_t)(reg) & 0x03u) >> 0u)
#define BME280_CTRL_MEAS_MODE_SET(reg, val)            (((uint8_t)(reg) & (uint8_t)~0x03u) | (((uint8_t)(val) << 0u) & 0x03u))
#define BME280_CTRL_MEAS_MODE_SLEEP                    0x00u  /* No measurements, minimum power */
#define BME280_CTRL_MEAS_MODE_FORCED                   0x01u  /* One measurement, then return to sleep */
#define BME280_CTRL_MEAS_MODE_FORCED_ALT               0x02u  /* Alternate encoding of forced mode */

Compared with

Related parts

BMP280
Bosch Sensortec
11 registers
ADXL345
Analog Devices
30 registers
DS1307
Analog Devices
8 registers

Source

Transcribed from BST-BME280-DS002 (hand-transcribed) (hand-transcribed). Hand-authored seed entry, not machine-extracted. Check against BST-BME280-DS002 before trusting it, then mark it verified.

Raw JSON · Report an error