SGP40.VocIndex (sgp40 v0.1.2) View Source

Process the raw output of the SGP40 sensor into the VOC Index.

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Get current algorithm states. Retrieved values can be used in set_states/1 to resume operation after a short interruption, skipping initial learning phase. This feature can only be used after at least 3 hours of continuous operation.

Calculate the VOC index value from the raw sensor value.

Set previously retrieved algorithm states to resume operation after a short interruption, skipping initial learning phase. This feature should not be used after inerruptions of more than 10 minutes. Call this once after start_link/1 and the optional set_tuning_params/1, if desired. Otherwise, the algorithm will start with initial learning phase.

Set parameters to customize the VOC algorithm. Call this once after start_link/1, if desired. Otherwise, the default values will be used.

Initialize the VOC algorithm parameters. Call this once at the beginning or whenever the sensor stopped measurements.

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Specs

get_states() :: {:ok, %{mean: integer(), std: integer()}} | {:error, any()}

Get current algorithm states. Retrieved values can be used in set_states/1 to resume operation after a short interruption, skipping initial learning phase. This feature can only be used after at least 3 hours of continuous operation.

Specs

process(0..65535) :: {:ok, 1..500} | {:error, any()}

Calculate the VOC index value from the raw sensor value.

Specs

set_states(%{mean: integer(), std: integer()}) ::
  {:ok, binary()} | {:error, any()}

Set previously retrieved algorithm states to resume operation after a short interruption, skipping initial learning phase. This feature should not be used after inerruptions of more than 10 minutes. Call this once after start_link/1 and the optional set_tuning_params/1, if desired. Otherwise, the algorithm will start with initial learning phase.

Specs

set_tuning_params(%{
  voc_index_offset: 0..2_147_483_647,
  learning_time_hours: 0..2_147_483_647,
  gating_max_duration_minutes: 0..2_147_483_647,
  std_initial: 0..2_147_483_647
}) :: {:ok, binary()} | {:error, any()}

Set parameters to customize the VOC algorithm. Call this once after start_link/1, if desired. Otherwise, the default values will be used.

Specs

start_link(any()) :: GenServer.on_start()

Initialize the VOC algorithm parameters. Call this once at the beginning or whenever the sensor stopped measurements.