BMP388 BMP390 Pressure & Temperature Sensors
Contents
BMP388/BMP390 Description
The BMP388 and BMP390 barometric pressure and temperature sensor chips are manufactured by Bosch Sensortec., a subsidiary of the German Bosch Group. They are the successor to the very successful BMP280.
Foremost they are regarded as barometric pressure sensors. The temperature sensing capability is an added bonus for the user. Temperature is required as part of the compensation calculations to convert the raw digital pressure to real pressure values.
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 improved upon this. This has now been followed with the release of the BMP3xx series.
The BMP3xx series includes the BMP384, a gel-filled sensor which makes it waterproof. This model won't be discussed further here. We purchased BMP388 and BMP390 breakout boards for this article and development of the MicroPython driver. However the MicroPython driver (for the micro:bit) referenced at the end of this article should still work fine with the BMP384.
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.
BMP388 and BMP390 Comparison
The values in the following table have been sourced from the respective product datasheets.
| BMP388 | BMP390 | |
|---|---|---|
| Package size (mm) | 2 x 2 x 0.75 | 2 x 2 x 0.75 |
| Pressure range (hPa) | 300-1250 | 300-1250 |
| Voltage | 1.65 - 3.6 | 1.65 - 3.6 |
| Typical peak conversion current (µA) |
700 | 660 |
| Current @ 1 SPS, lowest power setting (µA) |
3.4 | 3.2 |
| Typical sleep current (µA) | 2.0 | 1.4 |
| Pressure - relative accuracy (hPa) |
±0.08 | ±0.03 |
| Pressure - absolute accuracy (hPa) |
±0.50 | ±0.33 |
| Temperature - absolute accuracy @25°C (°C) |
±0.3 | ±0.5 |
Clearly the BMP390 has lower power requirements and higher pressure accuracy than its predecessor.
BMP3xx Pinout
The pinouts of the BMP388 and BMP390 are identical and have been sourced from the product Datasheet.
The BMP3xx continue the tradition of the BMP280 with both I2C and SPI serial interfaces available.
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 I2C interface. I2C has the advantage of being 2-wire, easy to use and reliable.
The 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.
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 precisionTemperature and precision is independently controlled by the user specifying oversampling parameters which are written to the Over Sampling register [OSR]. The available oversampling options available are x1, x2, x4, x8, x16 and x32. Generally temperature isn't oversampled beyond x2. However increasing the oversampling of pressure right up to the limit of x32 substantially increases precision and reduces signal noise.
Additionally, the BMP3xx sensors have a bandwidth filter known as the IIR filter. This filter has eight 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 ModeThe simplest method of taking a measurement is the one-shot user initiated mode. A measurement is forced by writing 0b01 to the mode bits which are bits[5:4] of the Power Control [PWR_CTRL] register.
Temperature and pressure uncompensated values are then read from the separate respective Data 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 ModeNormal mode continuously cycles an active measurement cycle followed by an inactive standby period. This standby time determines the frequency of the continuous read cycle. The measurement cycle time is user configurable.
Normal mode is started by writing 0b11 to the mode[1:0] bits of the Control Measurement [ctrl_meas] register.
The measurement cycle time is set by writing a value (odr_sel) between 0 and 17 inclusive to the Output Data Rate register [ODR]. The sensor calculates the measurement cycle time in milliseconds from the odr_sel as follows:
- Cycle Time = 5 * 2odr_sel
The chosen odr_sel value must provide a long enough sample time to allow the conversion to complete. This will depend upon which oversampling options have been configured. Insufficient conversion time will result in any value returned from the sensor being meaningless.
Converting uncompensated valuesThis is probably the hardest part 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 BMP3xx 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.
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. This integer version must be extracted from the API code that's available on GitHub.
FIFO Queue
This is a new feature to the BMPxxx barometric pressure sensor series. It incorporates a 512 byte FIFO (First In - First Out) queue.
In our view this is a worthwhile feature but somewhat overly complicated in practice. It allows the automatic storage of uncompensated pressure and/or temperature values.
This allows a busy microcontroller to carry on with other tasks and be notified by an external interrupt when the queue is full (or near full). At this point the microcontroller can burst read the entire FIFO queue, sort the data records into type and apply the compensation calculations.
The number of data records in the queue can be acquired at any time. Burst reading the records automatically deletes them from the FIFO queue. However if the records currently stored are not required then the FIFO can be separately flushed.
There is, of course, much more to it then this brief summary. For more details read the relevant product Datasheet.
BMP388/BMP390 Chip ID
Genuine Bosch BMP388 and BMP390 chips have the ID values 0x50 and 0x60 respectively written to read-only memory at point of manufacture. This value can be read from the ID value register [CHIP_ID].
Additionally, the BMP390 has what the datasheet calls the ASIC (Application-Specific Integrated Circuit) mask revision or REV_ID. The BMP390's REV_ID is 0x01. This can be read from the [REV_ID] register.
BMP3xx MicroPython Driver for micro:bit
A BMP3xx MicroPython driver specifically for the BBC micro:bit has been developed as part of this series on MicroPython for the microbit. This driver will work for the BMP388, BMP390 (and BMP384) sensors. The driver webpage also provides a detailed description of the driver's methods and properties with sample code.
The driver implements a fair slice of the capabilities as described in the product Datasheets. Two specifically configured sampling modes - low power/lower resolution and higher power, best resolution - are offered. A basic FIFO queue is also provided that will allow the user to explore this feature.
Also included are some basic altitude calculations.
Inertial Measurement, Magnet Field Sensing
How they work
Weather Station Sensors
How they work
Pressure, Humidity, Temperature
Distance Sensors
Images
BMP388 breakout board
Micrograph of the BMP388 chip
BMP390 breakout board
Micrograph: Breakout board's 10kΩ pullup resistors and logic level converter chip
Micrograph: breakout board's LDO 3.3V regulator chip