Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mnishiguchi/scd4x
Use Sensirion SCD4x CO2 sensors (SCD40 and SCD41) in Elixir
https://github.com/mnishiguchi/scd4x
co2-sensor elixir elixir-lang elixir-language nerves nerves-project scd40 scd41 scd4x scd4x-sensor sensor sensors
Last synced: about 2 months ago
JSON representation
Use Sensirion SCD4x CO2 sensors (SCD40 and SCD41) in Elixir
- Host: GitHub
- URL: https://github.com/mnishiguchi/scd4x
- Owner: mnishiguchi
- License: mit
- Created: 2021-08-22T01:46:59.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-08-28T13:04:54.000Z (over 3 years ago)
- Last Synced: 2024-10-30T21:39:12.463Z (2 months ago)
- Topics: co2-sensor, elixir, elixir-lang, elixir-language, nerves, nerves-project, scd40, scd41, scd4x, scd4x-sensor, sensor, sensors
- Language: Elixir
- Homepage:
- Size: 19.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# SCD4X
[![Hex version](https://img.shields.io/hexpm/v/scd4x.svg 'Hex version')](https://hex.pm/packages/scd4x)
[![API docs](https://img.shields.io/hexpm/v/scd4x.svg?label=docs 'API docs')](https://hexdocs.pm/scd4x)
[![CI](https://github.com/mnishiguchi/scd4x/actions/workflows/ci.yml/badge.svg)](https://github.com/mnishiguchi/scd4x/actions/workflows/ci.yml)
[![Publish](https://github.com/mnishiguchi/scd4x/actions/workflows/publish.yml/badge.svg)](https://github.com/mnishiguchi/scd4x/actions/workflows/publish.yml)Use [Sensirion SCD4X](https://www.sensirion.com/en/environmental-sensors/carbon-dioxide-sensors/carbon-dioxide-sensor-scd4x) [CO2](https://en.wikipedia.org/wiki/Carbon_dioxide) sensors (SCD40 and SCD41) in Elixir.
## Usage
### Start the sensor server
```elixir
iex> {:ok, scd} = SCD4X.start_link(bus_name: "i2c-1")
{:ok, #PID<0.1407.0>}
```### Periodic measurement
The sensor updates the measurement every 5 seconds once the periodic measurement is started.
```elixir
iex> SCD4X.start_periodic_measurement(scd)
:okiex> SCD4X.measure(scd)
{:ok,
%SCD4X.Measurement{
co2_ppm: 612,
humidity_rh: 59.07440185546875,
temperature_c: 30.331497192382812,
timestamp_ms: 620482
}}SCD4X.stop_periodic_measurement(scd)
:ok
```### Single shot measurement
The measurement can be performed on demand without the periodic measurement.
```elixir
iex> SCD4X.measure(scd, :single_shot)
{:ok,
%SCD4X.Measurement{
co2_ppm: 638,
humidity_rh: 70.49713134765625,
temperature_c: 26.63848876953125,
timestamp_ms: 400768
}}
```