Robot Control Library
Barometer_BMP

Description

Interface to the BMP280 barometer.

<rc/bmp.h>

Author
James Strawson
Date
3/14/2018

Data Structures

struct  rc_bmp_data_t
 

Typedefs

typedef enum rc_bmp_oversample_t rc_bmp_oversample_t
 
typedef enum rc_bmp_filter_t rc_bmp_filter_t
 
typedef struct rc_bmp_data_t rc_bmp_data_t
 

Functions

int rc_bmp_init (rc_bmp_oversample_t oversample, rc_bmp_filter_t filter)
 powers on the barometer and initializes it with the given oversample and filter settings. More...
 
int rc_bmp_set_sea_level_pressure_pa (double pa)
 If you know the current sea level pressure for your region and weather, you can use this to correct the altititude reading. More...
 
int rc_bmp_power_off (void)
 Puts the barometer into a low power state, should be called at the end of your program before close. More...
 
int rc_bmp_read (rc_bmp_data_t *data)
 Reads the newest temperature and pressure measurments from the barometer over the I2C bus. More...
 

Enumeration Type Documentation

◆ rc_bmp_oversample_t

Setting given to rc_bmp_init which defines the oversampling done internally to the barometer. For example, if BMP_OVERSAMPLE_16 is used then the barometer will average 16 samples before updating the data registers. The more oversampling used, the slower the data registers will update. You should pick an oversample that provides an update rate slightly slower than the rate at which you will be reading the barometer.

Enumerator
BMP_OVERSAMPLE_1 

update rate 182 HZ

BMP_OVERSAMPLE_2 

update rate 133 HZ

BMP_OVERSAMPLE_4 

update rate 87 HZ

BMP_OVERSAMPLE_8 

update rate 51 HZ

BMP_OVERSAMPLE_16 

update rate 28 HZ

◆ rc_bmp_filter_t

Setting given to rc_bmp_init to configure the coefficient of the internal first order filter. We recommend disabling the filter with BMP_FILTER_OFF and doing your own filtering with the discrete filter functions below.

Enumerator
BMP_FILTER_OFF 
BMP_FILTER_2 
BMP_FILTER_4 
BMP_FILTER_8 
BMP_FILTER_16 

Function Documentation

◆ rc_bmp_init()

int rc_bmp_init ( rc_bmp_oversample_t  oversample,
rc_bmp_filter_t  filter 
)

powers on the barometer and initializes it with the given oversample and filter settings.

Optionally call rc_bmp_set_sea_level_pressure_pa afterwards to change the sea level pressure from default.

Parameters
[in]oversamplesee rc_bmp_oversample_t
[in]filtersee rc_bmp_filter_t
Returns
0 on success, otherwise -1.
Examples:
rc_altitude.c, and rc_test_bmp.c.

◆ rc_bmp_set_sea_level_pressure_pa()

int rc_bmp_set_sea_level_pressure_pa ( double  pa)

If you know the current sea level pressure for your region and weather, you can use this to correct the altititude reading.

This is not necessary if you only care about differential altitude from a starting point. Must be called after rc_bmp_init to have an effect.

Parameters
[in]pasea level pressure in pascals
Returns
0 on success, -1 on failure

◆ rc_bmp_power_off()

int rc_bmp_power_off ( void  )

Puts the barometer into a low power state, should be called at the end of your program before close.

Returns
0 on success, -1 on failure
Examples:
rc_altitude.c, and rc_test_bmp.c.

◆ rc_bmp_read()

int rc_bmp_read ( rc_bmp_data_t data)

Reads the newest temperature and pressure measurments from the barometer over the I2C bus.

Parameters
datapointer to data struct where new data will be written.
Returns
0 on success, -1 on failure
Examples:
rc_altitude.c, and rc_test_bmp.c.