View Source BMP280 (bmp280 v0.2.13)

Read temperature and pressure from a Bosch BM280, BME280, or BME680 sensor

Summary

Types

BMP280 GenServer start_link options

The type of sensor in use

Functions

Returns a specification to start this module under a supervisor.

Detect the type of sensor that is located at the I2C address

Force the altitude to a known value

Measure the current temperature, pressure, altitude

read(server) deprecated

Return the type of sensor

Start a new GenServer for interacting with a BMP280

Update the sea level pressure estimate

Types

@type options() :: [
  name: GenServer.name(),
  bus_name: String.t(),
  bus_address: 118 | 119,
  sea_level_pa: number()
]

BMP280 GenServer start_link options

  • :name - a name for the GenServer
  • :bus_name - which I2C bus to use (e.g., "i2c-1")
  • :bus_address - the address of the BMP280 (defaults to 0x77)
  • :sea_level_pa - a starting estimate for the sea level pressure in Pascals
@type sensor_type() :: :bmp180 | :bmp280 | :bme280 | :bme680 | 0..255

The type of sensor in use

If the sensor is unknown, then number in the parts ID register is used.

Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

detect(bus_name, bus_address \\ 119)

View Source
@spec detect(String.t(), 118 | 119) :: {:ok, sensor_type()} | {:error, any()}

Detect the type of sensor that is located at the I2C address

If the sensor is a known BMP280 or BME280 the response will either contain :bmp280 or :bme280. If the sensor does not report back that it is one of those two types of sensors the return value will contain the id value that was reported back form the sensor.

The bus address is likely going to be 0x77 (the default) or 0x76.

Link to this function

force_altitude(server, altitude_m)

View Source
@spec force_altitude(GenServer.server(), number()) :: :ok | {:error, any()}

Force the altitude to a known value

Altitude calculations depend on the accuracy of the sea level pressure estimate. Since the sea level pressure changes based on the weather, it needs to be kept up to date or altitude measurements can be pretty far off. Another way to set the sea level pressure is to report a known altitude. Call this function with the current altitude in meters.

This function returns an error if the attempt to sample the current barometric pressure fails.

@spec measure(GenServer.server()) :: {:ok, BMP280.Measurement.t()} | {:error, any()}

Measure the current temperature, pressure, altitude

An error is return if the I2C transactions fail.

This function is deprecated. Use BMP280.measure/1 instead.
@spec sensor_type(GenServer.server()) :: sensor_type()

Return the type of sensor

This function returns the cached result of reading the ID register. if the part is recognized. If not, it returns the integer read.

@spec start_link(options()) :: GenServer.on_start()

Start a new GenServer for interacting with a BMP280

Normally, you'll want to pass the :bus_name option to specify the I2C bus going to the BMP280.

Link to this function

update_sea_level_pressure(server, new_estimate)

View Source
@spec update_sea_level_pressure(GenServer.server(), number()) :: :ok

Update the sea level pressure estimate

The sea level pressure should be specified in Pascals. The estimate is used for altitude calculations.