ex_co2_mini v0.1.2 ExCO2Mini.Collector
Collects data packets from a ExCO2Mini.Reader
instance and provides simple on-demand access to CO₂ and temperature data.
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor
Returns the CO₂ concentration, in parts per million (ppm)
Creates a process to collect data
Returns the ambient temperature, in degrees centigrade (°C)
Link to this section Functions
child_spec(init_arg)
Returns a specification to start this module under a supervisor.
See Supervisor
.
co2_ppm(pid)
Returns the CO₂ concentration, in parts per million (ppm).
start_link(opts)
Creates a process to collect data.
opts
is a keyword list. It accepts all of the options that GenServer.start_link/3
does, as well as the following:
opts[:reader]
(required) — The PID or name (atom) of aExCO2Meter.Reader
process.- The collector will automatically call
ExCO2Mini.Reader.subscribe/2
.
- The collector will automatically call
opts[:subscribe_as_name]
— If true, thenopts[:name]
must be included as well. The collector will subscribe using its name rather than PID.- This can be useful in preventing the
ExCO2Mini.Reader
process from accumulating defunct subscriptions if this collector is restarted repeatedly.
- This can be useful in preventing the
Returns {:ok, pid}
once the collector has been successfully started and has subscribed to the reader.
temperature(pid)
Returns the ambient temperature, in degrees centigrade (°C).