xref: /netbsd-src/share/man/man4/sgp40mox.4 (revision fd83225780cebcf64a60146c1d2332459d4ede76)
1.\" $NetBSD: sgp40mox.4,v 1.2 2021/10/14 21:35:45 wiz Exp $
2.\"
3.\" Copyright (c) 2021 Brad Spencer <brad@anduin.eldar.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd October 7, 2021
18.Dt SGP40MOX 4
19.Os
20.Sh NAME
21.Nm sgp40mox
22.Nd Driver for Sensirion SGP40 MOx gas sensor
23.Sh SYNOPSIS
24.Cd "sgp40mox* at iic? addr 0x59"
25.Sh DESCRIPTION
26The
27.Nm
28driver provides an air quality measurement from the SGP40
29sensor via the
30.Xr envsys 4
31framework.
32The
33.Nm
34.Ar addr
35argument selects the address at the
36.Xr iic 4
37bus.
38The crc validity and temperature and %RH compensation can be changed through
39.Xr sysctl 8
40nodes.
41.Pp
42In order to calculate the VOC index, the volatile organic compounds index, which
43is the measure of air quality the sensor is polled once a second and the raw sensor
44value is fed into the Sensirion VOC algorithm.
45This VOC algorithm used in this driver is licensed under a 3 clause
46BSD license and was pulled from the Sensirion Github repository at
47.Rs
48.%U https://github.com/Sensirion/embedded-sgp
49.Re
50.Sh SYSCTL VARIABLES
51The following
52.Xr sysctl 3
53variables are provided:
54.Bl -tag -width indent
55.It Li hw.sgp40mox0.compensation.temperature
56This should be set to the temperature in Celsius of the environment that the sensor
57is in.
58The valid values are from -45 to 130 degrees Celsius.
59.It Li hw.sgp40mox0.compensation.humidity
60This should be set to the %RH of the environment that the sensor is in.
61The valid values are from 0 to 100.
62.Pp
63For the best performance of the VOC algorithm it is important that the temperature
64and %RH compensation values be current and set using the
65.Xr sysctl 3
66variables mentioned above.
67This data will need to be pulled from another source, such as a another sensor in
68the environment that the SGP40 is in.
69.It Li hw.sgp40mox0.ignorecrc
70If set, the crc calculation will be ignored on the calls to the chip for the purposes
71of measurement.
72.It Li hw.sgp40mox0.debug
73If the driver is compiled with
74.Dv SGP40_DEBUG ,
75this node will appear and can be used to set the debugging level.
76.It Li hw.sgp40mox0.readattempts
77To read the air quality metric from the chip requires that the command be sent,
78then a delay must be observed before a read can be done to get the values
79back.
80The delays are documented in the data sheet for the chip.
81The driver will attempt to read back the values readattempts number of
82times.
83The default is 10 which should be more than enough for most purposes.
84.El
85.Sh SEE ALSO
86.Xr envsys 4 ,
87.Xr iic 4 ,
88.Xr envstat 8 ,
89.Xr sysctl 8
90.Sh HISTORY
91The
92.Nm
93driver first appeared in
94.Nx 10.0 .
95.Sh AUTHORS
96.An -nosplit
97The
98.Nm
99driver was written by
100.An Brad Spencer Aq Mt brad@anduin.eldar.org .
101.Sh BUGS
102The driver does not make complete use of the VOC algorithm.
103In particular, there is no need to restart the algorithm from
104scratch if there is a stoppage of polling for less than 10 minutes.
105The driver does not have the ability to determine that, and therefore
106assumes that the sensor is completely cold each time the driver attaches to the chip.
107.Pp
108The temperature and humidity compensation could be allowed to contain fractional degrees Celsius
109and %RH.
110The driver only supports setting whole numbers for either of those.
111