BMP280 Pressure & Temperature Sensor

Contents

BMP280 Sensor Description

BMP280 chip, showing its shape and dimensions
Fig 1 - BMP280 sensor

The BMP280 temperature and barometric pressure sensor chip is manufactured by Bosch Sensortec., a subsidiary of the German Bosch Group. It's described in the product Datasheet as the successor to the widely adopted BMP180.

The BMP085 was the first of a new generation of high precision digital pressure sensors. The second generation BMP180 offered better accuracy, wider voltage range with lower power consumption. The third generation BMP280 further improves upon this.

As of June, 2024 the BMP280 has been discontinued by Bosch Sensortec. However at time of writing (May 2025) they are still widely available through online shops (especially Chinese) as inexpensive breakout boards.

Temperature is measured with a bandgap temperature type sensor. This class of sensor relies upon the temperature dependent voltage characteristic of a silicon diode. It is the most common technology used in this type of temperature sensor.

Barometric pressure is measured with a piezo-resistive based sensor.

The supply voltage for this sensor is 1.71V to 3.6V. None of the boards we purchased for the development of the MicroPython driver had an on board LDO voltage regulator.

The peak current draw during a conversion is typically around 720 µA. At one sample per second in forced mode (and lowest power settings) the average current used is only 2.8 µA. In Standby the current draw is typically <0.5 µA.

Sensor Resolution and Precision

Precision and resolution are two different concepts often confused. Precision refers to the consistency or repeatability of measurements. Resolution is the number of bits required to hold the digital value after the ADC (Analog to Digital Converter) has done its work.

Pressure and temperature precision (reproducibility) are independently configurable by specifying over-sampling parameters.

The BMP280 temperature uncompensated output is configurable for 16-bit to 20-bit resolution. However the Datasheet advises that configuring a temperature resolution output greater than 17-bits won't substantially improve precision.

Pressure resolution is also configurable for 16-bits to 20-bits and unlike temperature, increasing the resolution of the pressure reading will also continue to increase the precision.

Sensor Packaging

The BMP280 IC is available in a single package type; an 8-pin (pads), LGA (Land Grid Array) package with metal lid. Its measurements are 2.0mm x 2.5mm x 0.95mm. This is a 63% reduced footprint compared to its BMP180 predecessor.

BMP280 Pinout

The following pinouts are from the product Datasheet.

BMP280 chip pinout from the Datasheet
Fig 2 - BMP280 IC pinout

Unlike the BMP180 which only has the one serial interface; I2C, the BMP280 has both I2C and SPI serial interfaces.

I2C Interface

Serial interface selection (I2C or SPI) is done automatically based on the status of the CSB (Chip Select) line. If pulled High, I2C is active. Similarly, if CSB is pulled Low then SPI is active.

Many users will choose to use the BMP280's I2C interface to communicate with the sensor. I2C has the advantage of being 2-wire, easy to use and reliable.

The BMP280's I2C interface is compatible with the international Philips standard and supports standard, fast and high-speed modes up to 3.4 Mbit/sec.

There is a choice of two I2C addresses:

  • 0x76 : SDO pin connected to GND
  • 0x77 : SDO pin connected to VDDIO.

BMP280 Registers

The BMP280 has a richer set of user accessible registers than the BMP180.

  • 6 x Measurement registers; 3 for temperature, 3 for pressure.
  • 1 x Configuration register
  • 1 x Measurement Control register
  • 1 x Soft Reset register
  • 1 x ID value register
  • 24 x registers with calibration constants

The BMP180 has only three Measurement registers (shared by temperature and pressure uncompensated values). The BMP280 has a separate set of registers for each of temperature and pressure values.

The BMP280's Configuration register is needed for IIR filter (discussed below) parameters and a bit which determines the active interface (I2C or SPI). The BMP180 has neither of these features.

Temperature & Pressure Measurements

Bosch refer to the 'raw' conversion values read from the Measurement registers as uncompensated.

This section will briefly examine options available to the user to set how sampling occurs, the precision of the results returned and the conversion of the uncompensated values to real units.

Setting precision

Temperature and precision is independently controlled by the user specifying over-sampling parameters which are written to the Measurement Control register [ctrl_meas].

Additionally, the BMP280 has a bandwidth filter known as the IIR filter. This filter has five separate levels (coefficients) which increasingly reduce the sample bandwidth.

This sensor is very sensitive to minor pressure variations such as caused by a door closing or groups of people moving past. The IIR filter is designed to significantly reduce or even eliminate such noise source interference.

Forced Mode

The simplest method of taking a measurement is the one-shot user initiated mode. This is inherited from its BMP180 predecessor. A measurement is forced by writing 0b01 to the mode[1:0] bits of the Control Measurement [ctrl_meas] register.

Temperature and pressure uncompensated values are then read from the separate respective Measurement registers after the conversions have completed.

Bosch refers to this one-shot measurement type as Forced mode. In Forced mode the user initiates a read. After the conversion has completed the sensor drops into a very low current sleep state till another read is initiated.

Normal Mode

Normal mode continuously cycles an active measurement cycle followed by an inactive standby period. This standby time determines the frequency of the continuous read cycle and is user configurable.

Normal mode is started by writing 0b11 to the mode[1:0] bits of the Control Measurement [ctrl_meas] register.

Converting uncompensated values

This is probably the hardest step of all as it involves some serious maths.

The first step is for the microcontroller to read in the calibration constants. This will usually be done in the driver's constructor.

These constants are unique for each BMP280 chip and are determined and written to EEPROM at the time of manufacture. Care needs to be taken as they are a mixture of signed and unsigned 16-bit integers.

Bosch provide an API and recommend that this is used to do the two uncompensated conversions. The API is coded in C, thus not an easy option when the language of choice is MicroPython.

However, Bosch do provide sample C code with all the mathematical equations shown in their product Datasheet. It involves some serious floating point maths which doesn't suit MicroPython with its native single precision floats.

However, Bosch also provide the equations in integer maths form that uses bit shifting operations to do most of the heavy lifting. MicroPython excels in this case and retains good precision. See Appendix 1 of the Datasheet for the equations.

BMP280 Soft Reset

The BMP280 can be soft reset by writing a given command to the Soft Reset register. This reinitialises the IC and sets all register values to their power-on defaults.

BMP280 ID

Genuine Bosch BMP280 chips have the ID value 0x58 written to read-only memory at point of manufacture. This value can be read from the ID value register.

BMP280 MicroPython Driver for micro:bit

A BMP280 MicroPython driver specifically for the BBC micro:bit has been developed as part of this series on MicroPython for the microbit. The driver webpage also provides a detailed description of the driver's methods with sample code.

The driver implements a fair slice of the BMP280 capabilities as described in the product Datasheet. However for ease of use and to save scarce flash memory on the micro:bit only forced mode is available. In most cases this is not a huge limitation.