BMP3XX (bmp3xx v0.1.0) View Source

Read pressure and temperature from a Bosch BMP388 or BMP390 sensor

Link to this section Summary

Types

BMP3XX GenServer start_link options

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

Return the type of sensor

Start a new GenServer for interacting with a BMP3XX

Update the sea level pressure estimate

Link to this section Types

Specs

bus_address() :: 118 | 119

Specs

options() :: [
  name: GenServer.name(),
  bus_name: binary(),
  bus_address: bus_address(),
  sea_level_pa: 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

Specs

sensor_type() :: :bmp388 | :bmp390

Link to this section 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

Specs

detect(binary(), bus_address()) :: {:ok, sensor_type()} | {:error, any()}

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

If the sensor is a known BMP3XX sensor, the response will either contain :bmp388 or :bmp390. 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 \\ __MODULE__, altitude_m)

View Source

Specs

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

Specs

measure(GenServer.server()) :: {:ok, struct()} | {:error, any()}

Measure the current temperature, pressure, altitude

An error is return if the I2C transactions fail.

Link to this function

sensor_type(server \\ __MODULE__)

View Source

Specs

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.

Specs

start_link(options()) :: 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

Specs

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.