View Source BMP3XX (bmp3xx v0.1.7)

Read temperature and pressure in Elixir from Bosch environmental sensors such as BMP180, BMP280, BME280, BMP384, BMP388, BMP390, BME680, BME688, etc.

Summary

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

Start a new GenServer for interacting with a BMP3XX

Update the sea level pressure estimate

Types

@type bmp2_sensor_type() :: :bmp180 | :bmp280 | :bme280 | :bme680
@type bmp3_sensor_type() :: :bmp380 | :bmp390
@type bus_address() :: 118 | 119
@type option() ::
  {:name, GenServer.name()}
  | {:bus_name, binary()}
  | {:bus_address, bus_address()}
  | {:sea_level_pa, number()}
  | {:retries, number()}

BMP3XX 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 BMP3XX (defaults to 0x77)
  • :sea_level_pa - a starting estimate for the sea level pressure in Pascals
  • :retries - the number of retries before failing (defaults to no retries)
@type sensor_type() :: bmp2_sensor_type() | bmp3_sensor_type()

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(binary(), bus_address()) :: {:ok, sensor_type()} | {:error, any()}

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

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

Link to this function

force_altitude(server \\ __MODULE__, 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.

Link to this function

measure(server \\ __MODULE__)

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

Measure the current temperature, pressure, altitude

An error is return if the I2C transactions fail.

@spec start_link([option()]) :: GenServer.on_start()

Start a new GenServer for interacting with a BMP3XX

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

Link to this function

update_sea_level_pressure(server \\ __MODULE__, 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.