MhZ19 (mh_z19 v0.1.1) View Source

A Elixir library to measure CO2 concentration value from MH-Z19 sensor.

Usage

iex> {:ok, pid} = MhZ19.start_link
{:ok, #PID<0.1104.0>}
iex> {:ok, result} = MhZ19.measure(pid)
{:ok,
 %MhZ19.Measurement{
   co2_concentration: 650
 }}

References

Link to this section Summary

Types

MhZ19 GenServer start_link options

Functions

Returns a specification to start this module under a supervisor.

Measures the current CO2 concentration value.

Starts a new GenServer process with given opts.

Link to this section Types

Specs

options() :: [name: GenServer.name(), tty: binary()]

MhZ19 GenServer start_link options

  • :name - a name for the GenServer (defaults to Elixir.MhZ19)
  • :tty - name of the serial device (defaults to "ttyAMA0")

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Specs

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

Measures the current CO2 concentration value.

Examples

iex> {:ok, result} = MhZ19.measure(pid)
{:ok,
 %MhZ19.Measurement{
   co2_concentration: 650
 }}

Specs

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

Starts a new GenServer process with given opts.

Examples

iex> {:ok, pid} = MhZ19.start_link