elixir-sensors / sgp40

Use Sensirion SGP40 air quality sensor in Elixir

Home Page:https://hex.pm/packages/sgp40

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SGP40

Hex version API docs CI Hex

Use Sensirion SGP40 air quality sensor in Elixir.

The raw signal from the SGP40 sensor is processed using Sensirion's software algorithm to give the VOC Index that represents an air quality value on a scale from 0 to 500 where a lower value represents cleaner air.

Usage

iex> {:ok, sgp} = SGP40.start_link(bus_name: "i2c-1")
{:ok, #PID<0.1407.0>}

iex> SGP40.measure(sgp)
{:ok, %SGP40.Measurement{voc_index: 123, timestamp_ms: 885906}}

For better accuracy, you can provide the SGP40 sensor with relative ambient humidity and ambient temperature from an external humidity sensor periodically.

iex> SGP40.update_rht(sgp, humidity_rh, temperature_c)
:ok

Depending on your hardware configuration, you may need to modify the call to SGP40.start_link/1. See t:SGP40.options/0 for parameters.

About

Use Sensirion SGP40 air quality sensor in Elixir

https://hex.pm/packages/sgp40

License:MIT License


Languages

Language:C 62.2%Language:Elixir 35.8%Language:Makefile 1.9%