SGP40 (sgp40 v0.1.7)

View Source

Use Sensirion SGP40 air quality sensor in Elixir

Summary

Types

SGP40 GenServer start_link options

Functions

Returns a specification to start this module under a supervisor.

Measure the current air quality.

Start a new GenServer for interacting with the SGP40 sensor. Normally, you'll want to pass the :bus_name option to specify the I2C bus going to the SGP40.

Update relative ambient humidity (RH %) and ambient temperature (degree C) for the humidity compensation.

Types

bus_address()

@type bus_address() :: 0..127

bus_name()

@type bus_name() :: binary()

options()

@type options() :: [
  name: GenServer.name(),
  bus_name: bus_name(),
  bus_address: bus_address(),
  humidity_rh: number(),
  temperature_c: number()
]

SGP40 GenServer start_link options

  • :name - A name for the GenServer
  • :bus_name - Which I2C bus to use (defaults to "i2c-1")
  • :bus_address - The address of the SGP40 (defaults to 0x59)
  • :humidity_rh - Relative humidity in percent for compensation
  • :temperature_c - Temperature in degree Celsius for compensation

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

get_states(server)

@spec get_states(GenServer.server()) ::
  {:ok, SGP40.VocIndex.AlgorithmStates.t()} | {:error, any()}

measure(server)

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

Measure the current air quality.

set_states(server, args)

@spec set_states(GenServer.server(), SGP40.VocIndex.AlgorithmStates.t()) ::
  {:ok, binary()} | {:error, any()}

set_tuning_params(server, args)

@spec set_tuning_params(GenServer.server(), SGP40.VocIndex.AlgorithmTuningParams.t()) ::
  {:ok, binary()} | {:error, any()}

start_link(init_arg \\ [])

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

Start a new GenServer for interacting with the SGP40 sensor. Normally, you'll want to pass the :bus_name option to specify the I2C bus going to the SGP40.

update_rht(server, humidity_rh, temperature_c)

@spec update_rht(GenServer.server(), number(), number()) :: :ok

Update relative ambient humidity (RH %) and ambient temperature (degree C) for the humidity compensation.