bmp280 - Driver for BMP280/BME280 digital pressure sensor

group bmp280

ESP-IDF driver for BMP280/BME280 digital pressure sensor.

Ported from esp-open-rtos

Copyright (C) 2016 sheinz https://github.com/sheinz

Copyright (C) 2018 Ruslan V. Uss

https://github.com/UncleRus

MIT Licensed as described in the file LICENSE

Defines

BMP280_I2C_ADDRESS_0

I2C address when SDO pin is low.

BMP280_I2C_ADDRESS_1

I2C address when SDO pin is high.

BMP280_CHIP_ID

BMP280 has chip-id 0x58.

BME280_CHIP_ID

BME280 has chip-id 0x60.

Enums

enum BMP280_Mode

Mode of BMP280 module operation.

Values:

enumerator BMP280_MODE_SLEEP

Sleep mode.

enumerator BMP280_MODE_FORCED

Measurement is initiated by user.

enumerator BMP280_MODE_NORMAL

Continues measurement.

enum BMP280_Filter

Values:

enumerator BMP280_FILTER_OFF
enumerator BMP280_FILTER_2
enumerator BMP280_FILTER_4
enumerator BMP280_FILTER_8
enumerator BMP280_FILTER_16
enum BMP280_Oversampling

Pressure oversampling settings.

Values:

enumerator BMP280_SKIPPED

no measurement

enumerator BMP280_ULTRA_LOW_POWER

oversampling x1

enumerator BMP280_LOW_POWER

oversampling x2

enumerator BMP280_STANDARD

oversampling x4

enumerator BMP280_HIGH_RES

oversampling x8

enumerator BMP280_ULTRA_HIGH_RES

oversampling x16

enum BMP280_StandbyTime

Stand by time between measurements in normal mode.

Values:

enumerator BMP280_STANDBY_05

stand by time 0.5ms

enumerator BMP280_STANDBY_62

stand by time 62.5ms

enumerator BMP280_STANDBY_125

stand by time 125ms

enumerator BMP280_STANDBY_250

stand by time 250ms

enumerator BMP280_STANDBY_500

stand by time 500ms

enumerator BMP280_STANDBY_1000

stand by time 1s

enumerator BMP280_STANDBY_2000

stand by time 2s BMP280, 10ms BME280

enumerator BMP280_STANDBY_4000

stand by time 4s BMP280, 20ms BME280

Functions

esp_err_t bmp280_init_desc(bmp280_t *dev, uint8_t addr, i2c_port_t port, gpio_num_t sda_gpio, gpio_num_t scl_gpio)

Initialize device descriptor.

Return

ESP_OK on success

Parameters
  • [out] dev: Pointer to device descriptor

  • [in] addr: BMP280 address

  • [in] port: I2C port number

  • [in] sda_gpio: GPIO pin for SDA

  • [in] scl_gpio: GPIO pin for SCL

esp_err_t bmp280_free_desc(bmp280_t *dev)

Free device descriptor.

Return

ESP_OK on success

Parameters
  • dev: Pointer to device descriptor

esp_err_t bmp280_init_default_params(bmp280_params_t *params)

Initialize default parameters.

Default configuration: mode: NORMAL filter: OFF oversampling: x4 standby time: 250ms

esp_err_t bmp280_init(bmp280_t *dev, bmp280_params_t *params)

Initialize BMP280 module, probes for the device, soft resets the device, reads the calibration constants, and configures the device using the supplied parameters.

Returns ESP_OK on success.

This may be called again to soft reset the device and initialize it again.

esp_err_t bmp280_force_measurement(bmp280_t *dev)

Start measurement in forced mode.

The module remains in forced mode after this call. Do not call this method in normal mode.

esp_err_t bmp280_is_measuring(bmp280_t *dev, bool *busy)

Check if BMP280 is busy with measuring temperature/pressure.

Return true if BMP280 is busy.

esp_err_t bmp280_read_fixed(bmp280_t *dev, int32_t *temperature, uint32_t *pressure, uint32_t *humidity)

Read compensated temperature and pressure data:

Temperature in degrees Celsius times 100.

Pressure in Pascals in fixed point 24 bit integer 8 bit fraction format.

Humidity is optional and only read for the BME280, in percent relative humidity as a fixed point 22 bit integer and 10 bit fraction format.

esp_err_t bmp280_read_float(bmp280_t *dev, float *temperature, float *pressure, float *humidity)

Read compensated temperature and pressure data: Temperature in degrees Celsius.

Pressure in Pascals. Humidity is optional and only read for the BME280, in percent relative humidity.

struct bmp280_params_t
#include <bmp280.h>

Configuration parameters for BMP280 module.

Use function bmp280_init_default_params to use default configuration.

struct bmp280_t
#include <bmp280.h>

Device descriptor.