UPM

The UPM API is a high level sensor library for IoT devices using MRAA. See examples here. Back to index page.
SparkFun sensor images provided under CC BY-NC-SA-3.0.

BMP280 Class

Module: bmp280

The BMP280 is an absolute barometric pressure sensor especially designed for mobile applications. The sensor module is housed in an extremely compact 8-pin metal-lid LGA package with a footprint of only 2.0 * 2.5 mm2 and 0.95 mm package height. Its small dimensions and its low power consumption of 2.7 uA @1Hz allow the implementation in battery driven devices such as mobile phones, GPS modules or watches.
As the successor to the widely adopted BMP180, the BMP280 delivers high performance in all applications that require precise pressure measurement. The BMP280 operates at lower noise, supports new filter modes and an SPI interface within a footprint 63% smaller than the BMP180.

Methods

BMP280

(
  • bus
  • addr
  • cs
)
Number

BMP280 constructor.
This driver supports both the BMP280 and the BME280 . The BME280 adds a humidity sensor. The device type is detected automatically by querying the chip id register.
This device can support both I2C and SPI. For SPI, set the addr to -1, and specify a positive integer representing the Chip Select (CS) pin for the cs argument. If you are using a hardware CS pin, then you can connect the proper pin to the hardware CS pin on your MCU and supply -1 for cs. The default operating mode is I2C.

Parameters:

  • bus Number

    I2C or SPI bus to use.

  • addr Number

    The I2C address for this device. Use -1 for SPI.

  • cs Number

    The gpio pin to use for the SPI Chip Select. Use -1 for I2C, or for SPI with a hardware controlled pin.

Returns:

Number:

update

()

Update the internal stored values from sensor data.

getChipID

() Number

Return the chip ID.

Returns:

Number:

The chip ID (BMP280_CHIPID).

reset

()

Reset the sensor, as if by a power-on-reset.

getTemperature

(
  • fahrenheit
)
Number

Return the current measured temperature. Note, this is not ambient temperature - this is the temperature used to fine tune the pressure measurement. update() must have been called prior to calling this method.

Parameters:

  • fahrenheit Boolean

    true to return data in Fahrenheit, false for Celicus. Celsius is the default.

Returns:

Number:

The temperature in degrees Celsius or Fahrenheit.

getPressure

() Number

Return the current measured pressure in Pascals (Pa). update() must have been called prior to calling this method.

Returns:

Number:

The pressure in Pascals (Pa).

setSeaLevelPreassure

(
  • seaLevelhPA
)

Set the pressure at sea level in hecto-Pascals (hPA). This value is used to compute the altitude based on the pressure. At driver initialization time, this value is set to 1013.25 hPA.

Parameters:

  • seaLevelhPA Number

    The pressure at sea level in hectoPascals (hPa). The default is 1013.25 hPA, (101325 Pa).

getAltitude

() Number

Return the current computed altitude in meters. update() must have been called prior to calling this method.

Returns:

Number:

The computed altitude in meters.

setUsageMode

(
  • mode
)

Set a general usage mode. This function can be used to configure the filters and oversampling for a particular use case. These setting are documented in the BMP280 datasheet. The default mode set in the constructor is USAGE_MODE_INDOOR_NAV, the highest resolution mode.

Parameters:

  • mode BMP280_USAGE_MODE_T

    One of the BMP280_USAGE_MODE_T values.

setOversampleRateTemperature

(
  • rate
)

Set the temperature sensor oversampling parameter. See the data sheet for details. This value can be automatically set to a suitable value by using one of the predefined modes for setUsageMode() .

Parameters:

  • rate BMP280_OSRS_T_T

    One of the BMP280_OSRS_T_T values.

setOversampleRatePressure

(
  • rate
)

Set the pressure sensor oversampling parameter. See the data sheet for details. This value can be automatically set to a suitable value by using one of the predefined modes for setUsageMode() .

Parameters:

  • rate BMP280_OSRS_P_T

    One of the BMP280_OSRS_P_T values.

setTimerStandby

(
  • tsb
)

Set the timer standby value. When in NORMAL operating mode, this timer governs how long the chip will wait before performing a measurement. See the data sheet for details.

Parameters:

  • tsb BMP280_T_SB_T

    One of the BMP280_T_SB_T values.

setFilter

(
  • filter
)

Set the IIR filtering parameter. See the data sheet for details. This value can be automatically set to a suitable value by using one of the predefined modes for setUsageMode() .

Parameters:

  • filter BMP280_FILTER_T

    One of the BMP280_FILTER_T values.

setMeasureMode

(
  • mode
)

Set the default measuring mode. Basic values are forced, sleep, and normal. See the data sheet for details. This value can be automatically set to a suitable value by using one of the predefined modes for setUsageMode() .

Parameters:

  • mode BMP280_MODES_T

    One of the BMP280_MODES_T values.

getModuleName

() String

Returns name of module. This is the string in library name after libupm_

Returns:

String:

name of module

getTemperatureCelsius

() Number

Returns:

Number:

getPressurePa

() Number

Returns:

Number: