xref: /freebsd/share/man/man4/gpioths.4 (revision 2e3f49888ec8851bafb22011533217487764fdb0)
1.\"-
2.\" SPDX-License-Identifier: BSD-2-Clause
3.\"
4.\" Copyright (c) 2019 Ian Lepore <ian@freebsd.org>
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25.\" SUCH DAMAGE.
26.\"
27.Dd December 8, 2019
28.Dt GPIOTHS 4
29.Os
30.Sh NAME
31.Nm gpioths
32.Nd driver for DHTxx and AM320x temperature and humidity sensors
33.Sh SYNOPSIS
34To compile this driver into the kernel,
35place the following line in your
36kernel configuration file:
37.Bd -ragged -offset indent
38.Cd "device gpioths"
39.Ed
40.Pp
41Alternatively, to load the driver as a
42module at boot time, place the following line in
43.Xr loader.conf 5 :
44.Bd -literal -offset indent
45gpioths_load="YES"
46.Ed
47.Sh DESCRIPTION
48The
49.Nm
50driver supports the DHTxx and AM320x family of
51temperature and humidity sensors.
52The driver automatically reads the values from the sensor
53once every 5 seconds, and makes the results available via
54.Xr sysctl 8
55variables.
56.Sh HARDWARE
57The
58.Nm
59driver provides support for the following devices:
60.Pp
61.Bl -column -compact -offset indent "XXXXXXXX" "XXXXXXXX"
62.It DHT11  Ta DHT12
63.It DHT21  Ta DHT22
64.It AM3201 Ta AM3202
65.El
66.Pp
67The supported devices are all similar to each other, varying
68primarily in accuracy and resolution.
69The devices require a single wire for data communications, using a
70custom protocol which is not compatible with Maxim's 1-wire(tm).
71The AM320x devices also support connection to an i2c bus,
72but this driver supports only the single-wire connection option.
73.Sh SYSCTL VARIABLES
74Sysctl variables are used to access the most recent temperature and
75humidity measurements.
76.Bl -tag -width indent
77.It Va dev.gpioths.<unit>.temperature
78The current temperature in integer deciKelvins.
79Note that
80.Xr sysctl 8
81will convert those units to display in decimal degrees Celsius.
82.It Va dev.gpioths.<unit>.humidity
83The current relative humidity, as an integer percentage.
84.It Va dev.gpioths.<unit>.fails
85The number of failed attempts to communicate with the sensor since
86the last good access.
87Cleared whenever a set of measurements is successfully retrieved.
88.El
89.Sh FDT CONFIGURATION
90On an
91.Xr fdt 4
92based system, a
93.Nm
94device node is typically defined directly under the root node, or under
95a simplebus node that represents a collection of devices on a board.
96.Pp
97The following properties are required in the
98.Nm
99device subnode:
100.Bl -tag -width indent
101.It Va compatible
102Must be "dht11".
103.It Va gpios
104A reference to the gpio device and pin for data communications.
105.El
106.Ss Example of adding a sensor with an overlay
107.Bd -unfilled -offset indent
108/dts-v1/;
109/plugin/;
110#include <dt-bindings/gpio/gpio.h>
111
112/ {
113    compatible = "wand,imx6q-wandboard";
114};
115
116&{/} {
117    dht0 {
118        compatible = "dht11";
119        gpios = <&gpio5 15 GPIO_ACTIVE_HIGH>;
120    };
121};
122.Ed
123.Sh HINTS CONFIGURATION
124On a
125.Xr device.hints 5
126based system, such as
127.Li MIPS ,
128these values are configurable for
129.Nm :
130.Bl -tag -width indent
131.It Va hint.gpioths.<unit>.at
132The
133.Xr gpiobus 4
134instance the
135.Nm
136instance is attached to.
137.It Va hint.gpioths.pins
138A bitmask with a single bit set to indicate which gpio pin on the
139.Xr gpiobus 4
140to use for data communications.
141.El
142.Sh SEE ALSO
143.Xr fdt 4 ,
144.Xr gpiobus 4 ,
145.Xr sysctl 8
146.Sh HISTORY
147The
148.Nm
149driver first appeared in
150.Fx 11.1 .
151