xref: /freebsd-src/share/man/man4/gpioths.4 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
19a57b9c3SIan Lepore.\"-
29a57b9c3SIan Lepore.\" SPDX-License-Identifier: BSD-2-Clause
39a57b9c3SIan Lepore.\"
49a57b9c3SIan Lepore.\" Copyright (c) 2019 Ian Lepore <ian@freebsd.org>
59a57b9c3SIan Lepore.\"
69a57b9c3SIan Lepore.\" Redistribution and use in source and binary forms, with or without
79a57b9c3SIan Lepore.\" modification, are permitted provided that the following conditions
89a57b9c3SIan Lepore.\" are met:
99a57b9c3SIan Lepore.\" 1. Redistributions of source code must retain the above copyright
109a57b9c3SIan Lepore.\"    notice, this list of conditions and the following disclaimer.
119a57b9c3SIan Lepore.\" 2. Redistributions in binary form must reproduce the above copyright
129a57b9c3SIan Lepore.\"    notice, this list of conditions and the following disclaimer in the
139a57b9c3SIan Lepore.\"    documentation and/or other materials provided with the distribution.
149a57b9c3SIan Lepore.\"
159a57b9c3SIan Lepore.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
169a57b9c3SIan Lepore.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
179a57b9c3SIan Lepore.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
189a57b9c3SIan Lepore.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
199a57b9c3SIan Lepore.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
209a57b9c3SIan Lepore.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
219a57b9c3SIan Lepore.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
229a57b9c3SIan Lepore.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
239a57b9c3SIan Lepore.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
249a57b9c3SIan Lepore.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
259a57b9c3SIan Lepore.\" SUCH DAMAGE.
269a57b9c3SIan Lepore.\"
279a57b9c3SIan Lepore.Dd December 8, 2019
289a57b9c3SIan Lepore.Dt GPIOTHS 4
299a57b9c3SIan Lepore.Os
309a57b9c3SIan Lepore.Sh NAME
319a57b9c3SIan Lepore.Nm gpioths
329a57b9c3SIan Lepore.Nd driver for DHTxx and AM320x temperature and humidity sensors
339a57b9c3SIan Lepore.Sh SYNOPSIS
349a57b9c3SIan LeporeTo compile this driver into the kernel,
359a57b9c3SIan Leporeplace the following line in your
369a57b9c3SIan Leporekernel configuration file:
379a57b9c3SIan Lepore.Bd -ragged -offset indent
389a57b9c3SIan Lepore.Cd "device gpioths"
399a57b9c3SIan Lepore.Ed
409a57b9c3SIan Lepore.Pp
419a57b9c3SIan LeporeAlternatively, to load the driver as a
429a57b9c3SIan Leporemodule at boot time, place the following line in
439a57b9c3SIan Lepore.Xr loader.conf 5 :
449a57b9c3SIan Lepore.Bd -literal -offset indent
459a57b9c3SIan Leporegpioths_load="YES"
469a57b9c3SIan Lepore.Ed
479a57b9c3SIan Lepore.Sh DESCRIPTION
489a57b9c3SIan LeporeThe
499a57b9c3SIan Lepore.Nm
509a57b9c3SIan Leporedriver supports the DHTxx and AM320x family of
519a57b9c3SIan Leporetemperature and humidity sensors.
529a57b9c3SIan LeporeThe driver automatically reads the values from the sensor
539a57b9c3SIan Leporeonce every 5 seconds, and makes the results available via
549a57b9c3SIan Lepore.Xr sysctl 8
559a57b9c3SIan Leporevariables.
569a57b9c3SIan Lepore.Sh HARDWARE
579a57b9c3SIan LeporeThe
589a57b9c3SIan Lepore.Nm
599a57b9c3SIan Leporedriver provides support for the following devices:
609a57b9c3SIan Lepore.Pp
619a57b9c3SIan Lepore.Bl -column -compact -offset indent "XXXXXXXX" "XXXXXXXX"
629a57b9c3SIan Lepore.It DHT11  Ta DHT12
639a57b9c3SIan Lepore.It DHT21  Ta DHT22
649a57b9c3SIan Lepore.It AM3201 Ta AM3202
659a57b9c3SIan Lepore.El
669a57b9c3SIan Lepore.Pp
679a57b9c3SIan LeporeThe supported devices are all similar to each other, varying
689a57b9c3SIan Leporeprimarily in accuracy and resolution.
699a57b9c3SIan LeporeThe devices require a single wire for data communications, using a
709a57b9c3SIan Leporecustom protocol which is not compatible with Maxim's 1-wire(tm).
719a57b9c3SIan LeporeThe AM320x devices also support connection to an i2c bus,
729a57b9c3SIan Leporebut this driver supports only the single-wire connection option.
739a57b9c3SIan Lepore.Sh SYSCTL VARIABLES
749a57b9c3SIan LeporeSysctl variables are used to access the most recent temperature and
759a57b9c3SIan Leporehumidity measurements.
769a57b9c3SIan Lepore.Bl -tag -width indent
77*74c303e4SJuraj Lutter.It Va dev.gpioths.<unit>.temperature
789a57b9c3SIan LeporeThe current temperature in integer deciKelvins.
799a57b9c3SIan LeporeNote that
809a57b9c3SIan Lepore.Xr sysctl 8
819097ac9aSElyes HAOUASwill convert those units to display in decimal degrees Celsius.
82*74c303e4SJuraj Lutter.It Va dev.gpioths.<unit>.humidity
839a57b9c3SIan LeporeThe current relative humidity, as an integer percentage.
849a57b9c3SIan Lepore.It Va dev.gpioths.<unit>.fails
859a57b9c3SIan LeporeThe number of failed attempts to communicate with the sensor since
869a57b9c3SIan Leporethe last good access.
879a57b9c3SIan LeporeCleared whenever a set of measurements is successfully retrieved.
889a57b9c3SIan Lepore.El
899a57b9c3SIan Lepore.Sh FDT CONFIGURATION
909a57b9c3SIan LeporeOn an
919a57b9c3SIan Lepore.Xr fdt 4
929a57b9c3SIan Leporebased system, a
939a57b9c3SIan Lepore.Nm
949a57b9c3SIan Leporedevice node is typically defined directly under the root node, or under
959a57b9c3SIan Leporea simplebus node that represents a collection of devices on a board.
969a57b9c3SIan Lepore.Pp
979a57b9c3SIan LeporeThe following properties are required in the
989a57b9c3SIan Lepore.Nm
999a57b9c3SIan Leporedevice subnode:
1009a57b9c3SIan Lepore.Bl -tag -width indent
1019a57b9c3SIan Lepore.It Va compatible
1029a57b9c3SIan LeporeMust be "dht11".
1039a57b9c3SIan Lepore.It Va gpios
1049a57b9c3SIan LeporeA reference to the gpio device and pin for data communications.
1059a57b9c3SIan Lepore.El
1069a57b9c3SIan Lepore.Ss Example of adding a sensor with an overlay
1079a57b9c3SIan Lepore.Bd -unfilled -offset indent
1089a57b9c3SIan Lepore/dts-v1/;
1099a57b9c3SIan Lepore/plugin/;
1109a57b9c3SIan Lepore#include <dt-bindings/gpio/gpio.h>
1119a57b9c3SIan Lepore
1129a57b9c3SIan Lepore/ {
1139a57b9c3SIan Lepore    compatible = "wand,imx6q-wandboard";
1149a57b9c3SIan Lepore};
1159a57b9c3SIan Lepore
1169a57b9c3SIan Lepore&{/} {
1179a57b9c3SIan Lepore    dht0 {
1189a57b9c3SIan Lepore        compatible = "dht11";
1199a57b9c3SIan Lepore        gpios = <&gpio5 15 GPIO_ACTIVE_HIGH>;
1209a57b9c3SIan Lepore    };
1219a57b9c3SIan Lepore};
1229a57b9c3SIan Lepore.Ed
1239a57b9c3SIan Lepore.Sh HINTS CONFIGURATION
1249a57b9c3SIan LeporeOn a
1259a57b9c3SIan Lepore.Xr device.hints 5
1269a57b9c3SIan Leporebased system, such as
1279a57b9c3SIan Lepore.Li MIPS ,
1289a57b9c3SIan Leporethese values are configurable for
1299a57b9c3SIan Lepore.Nm :
1309a57b9c3SIan Lepore.Bl -tag -width indent
1319a57b9c3SIan Lepore.It Va hint.gpioths.<unit>.at
1329a57b9c3SIan LeporeThe
1339a57b9c3SIan Lepore.Xr gpiobus 4
1349a57b9c3SIan Leporeinstance the
1359a57b9c3SIan Lepore.Nm
1369a57b9c3SIan Leporeinstance is attached to.
1379a57b9c3SIan Lepore.It Va hint.gpioths.pins
1389a57b9c3SIan LeporeA bitmask with a single bit set to indicate which gpio pin on the
1399a57b9c3SIan Lepore.Xr gpiobus 4
1409a57b9c3SIan Leporeto use for data communications.
1419a57b9c3SIan Lepore.El
1429a57b9c3SIan Lepore.Sh SEE ALSO
1439a57b9c3SIan Lepore.Xr fdt 4 ,
1449a57b9c3SIan Lepore.Xr gpiobus 4 ,
1459a57b9c3SIan Lepore.Xr sysctl 8
1469a57b9c3SIan Lepore.Sh HISTORY
1479a57b9c3SIan LeporeThe
1489a57b9c3SIan Lepore.Nm
1499a57b9c3SIan Leporedriver first appeared in
1509a57b9c3SIan Lepore.Fx 11.1 .
151