MhZ19 (mh_z19 v0.1.0) View Source

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

Installation

If available in Hex, the package can be installed by adding mh_z19 to your list of dependencies in mix.exs:

def deps do
  [
    {:mh_z19, "~> 0.1.0"}
  ]
end

Usage

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

References

Author

Kentaro Kuribayashi

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Initializes a GenServer process with given opts.

Retrieves the current CO2 concentration value.

Starts a GenServer process with given opts.

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Initializes a GenServer process with given opts.

Options

  • :tty - (String) Set the name of the serial device. Defaults to ttyAMA0.

Retrieves the current CO2 concentration value.

Examples

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

Starts a GenServer process with given opts.

Options

  • :name - (Atom) Set the name of the GenServer process. Defaults to MhZ19.

Examples

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