SGP40 (sgp40 v0.1.3) View Source

Use Sensirion SGP40 air quality sensor in Elixir

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

Link to this section Types

Specs

bus_address() :: 0..127

Specs

bus_name() :: binary()

Specs

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

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

See SGP40.VocIndex.get_states/0.

Specs

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

Measure the current air quality.

See SGP40.VocIndex.set_states/1.

See SGP40.VocIndex.set_tuning_params/1.

Link to this function

start_link(init_arg \\ [])

View Source

Specs

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.

Link to this function

update_rht(server, humidity_rh, temperature_c)

View Source

Specs

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

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