BMP280 - Barometric Pressure Sensor

Description

Driver for the Bosch Sensortec BMP280 barometric pressure sensor.


BMP280 example

Basic example for performing pressure measurement:

#include "sl_i2cspm_instances.h"
#include "sl_bmp280.h"

int main( void )
{

  ...

  float pressure;

  sl_bmp280_init(sl_i2cspm_sensor_env);
  sl_bmp280_measure_pressure(sl_i2cspm_sensor_env, &pressure);

  ...

} 

Data Structures

struct sl_bmp280_config
Structure to configure the BMP280 device.

Functions

sl_status_t sl_bmp280_init (sl_i2cspm_t *i2cspm)
Initialize the barometric pressure sensor chip.
void sl_bmp280_deinit (sl_i2cspm_t *i2cspm)
De-initialize the barometric pressure module.
sl_status_t sl_bmp280_configure (sl_i2cspm_t *i2cspm, sl_bmp280_config_t *cfg)
Configure the barometric pressure sensor.
sl_status_t sl_bmp280_measure_temperature (sl_i2cspm_t *i2cspm, float *temperature)
Initiate temperature measurement on the barometric pressure sensor and read temperature from it.
sl_status_t sl_bmp280_measure_pressure (sl_i2cspm_t *i2cspm, float *pressure)
Initiate pressure measurement on the barometric pressure sensor and read pressure from it.

Function Documentation

sl_bmp280_init()

sl_status_t sl_bmp280_init ( sl_i2cspm_t * i2cspm )

Initialize the barometric pressure sensor chip.

Parameters
[in] i2cspm The I2CSPM instance to use.
Return values
SL_STATUS_OK Success
SL_STATUS_FAIL Initialization failed

sl_bmp280_deinit()

void sl_bmp280_deinit ( sl_i2cspm_t * i2cspm )

De-initialize the barometric pressure module.

Parameters
[in] i2cspm The I2CSPM instance to use.

sl_bmp280_configure()

sl_status_t sl_bmp280_configure ( sl_i2cspm_t * i2cspm,
sl_bmp280_config_t * cfg
)

Configure the barometric pressure sensor.

Parameters
[in] i2cspm The I2CSPM instance to use.
[in] cfg Structure, which holds the configuration parameters
Note
Make sure to pass by Sleep Mode before switching between Forced mode and normal mode. Refer to datasheet for more details.
Return values
SL_STATUS_OK Success
SL_STATUS_FAIL Sensor configuration failed

sl_bmp280_measure_temperature()

sl_status_t sl_bmp280_measure_temperature ( sl_i2cspm_t * i2cspm,
float * temperature
)

Initiate temperature measurement on the barometric pressure sensor and read temperature from it.

Parameters
[in] i2cspm The I2CSPM instance to use.
[out] temperature The measured temperature in degrees Celsius
Return values
SL_STATUS_OK Success
SL_STATUS_FAIL Failure during temperature measurement/read

sl_bmp280_measure_pressure()

sl_status_t sl_bmp280_measure_pressure ( sl_i2cspm_t * i2cspm,
float * pressure
)

Initiate pressure measurement on the barometric pressure sensor and read pressure from it.

Parameters
[in] i2cspm The I2CSPM instance to use.
[out] pressure The measured pressure in millibars.
Return values
SL_STATUS_OK Success
SL_STATUS_FAIL Failure during pressure measurement/read