GPIOTHS(4)

πŸ’– GPIOTHS πŸ’– β€” the temperature + humidity sensor driver (section 4 of the Kernel Interfaces Manual, bestie 🫢)

okay so like. you know how sometimes you just need to know how hot and how moist the air is?? that's literally what this is. <rainbow>gpioths</rainbow> β€” driver for DHTxx and AM320x temperature and humidity sensors. it's a kernel interfaces manual page, so it lives in section 4. periodt. πŸŒ‘οΈπŸ’§


✨ NAME ✨

gpioths β€” driver for DHTxx and AM320x temperature and humidity sensors


πŸŽ€ SYNOPSIS πŸŽ€

so to compile this driver into the kernel (iykyk), you drop this line into your kernel configuration file:

device gpioths

or alternatively β€” if you'd rather load it as a module at boot time β€” put this line in loader.conf(5):

gpioths_load="YES"

both work. pick your fighter. πŸ’…


🌸 DESCRIPTION 🌸

The gpioths driver supports the DHTxx and AM320x family of temperature and humidity sensors. like, the whole squad.

the driver automatically reads the values from the sensor once every 5 seconds β€” no you don't have to poke it, it just does it, main character energy fr β€” and makes the results available via sysctl(8) variables. 🫢


πŸ¦‹ HARDWARE πŸ¦‹

the gpioths driver provides support for the following devices:

  • DHT11
  • DHT12
  • DHT21
  • DHT22
  • AM3201
  • AM3202

ngl they're all basically siblings β€” the supported devices are all similar to each other, varying primarily in accuracy and resolution. so like, same vibe, different specs.

they require a single wire for data communications, using a custom protocol which is not compatible with Maxim's 1-wire(tm). do not try it. it's giving "they are not the same" πŸ’€

the AM320x devices also support connection to an i2c bus, but β€” heads up β€” this driver supports only the single-wire connection option. so don't come for me about the i2c, it's not happening here. πŸ™ˆ


πŸ’œ SYSCTL VARIABLES πŸ’œ

sysctl variables are used to access the most recent temperature and humidity measurements. fresh data, no stale vibes. ✨

  • dev.gpioths.<unit>.temp β€” the current temperature in integer deciKelvins. note that sysctl(8) will convert those units to display in decimal degrees Celcius. so you get the cute Celcius readout even though the raw number is in deciKelvins. math is doing the heavy lifting so you don't have to. 🧚
  • dev.gpioths.<unit>.hum β€” the current relative humidity, as an integer percentage.
  • dev.gpioths.<unit>.fails β€” the number of failed attempts to communicate with the sensor since the last good access. it gets cleared whenever a set of measurements is successfully retrieved. so if this number is climbing, the sensor is ghosting you and you should go touch some wires. 😭

🌈 FDT CONFIGURATION 🌈

on an fdt(4) based system, a gpioths device node is typically defined directly under the root node, or under a simplebus node that represents a collection of devices on a board. either slaps, honestly.

the required properties (in the gpioths device subnode)

  • compatible β€” must be "dht11". yes even if it's not literally a DHT11, that's the string. that's the rule. πŸ’…
  • gpios β€” a reference to the gpio device and pin for data communications.

✨ example of adding a sensor with an overlay ✨

/dts-v1/;
/plugin/;
#include <dt-bindings/gpio/gpio.h>

/ {
    compatible = "wand,imx6q-wandboard";
};

&{/} {
    dht0 {
        compatible = "dht11";
        gpios = <&gpio5 15 GPIO_ACTIVE_HIGH>;
    };
};

look at that. gorgeous. no notes. πŸŽ€


⭐ HINTS CONFIGURATION ⭐

on a device.hints(5) based system, such as MIPS, these values are configurable for gpioths:

  • hint.gpioths.<unit>.at β€” the gpiobus(4) instance the gpioths instance is attached to.
  • hint.gpioths.pins β€” a bitmask with a single bit set to indicate which gpio pin on the gpiobus(4) to use for data communications. one bit. just one. don't be greedy. πŸ™ˆ

πŸ’– SEE ALSO πŸ’–

go read those too, bestie, they're part of the lore.


πŸ‘‘ HISTORY πŸ‘‘

the gpioths driver first appeared in FreeBSD 11.1. an icon. a legend. a moment. πŸ”₯


ok that's the whole page!! every flag, every path, every variable, every example β€” all still here, just with way better energy. 🌸

that's it bestie, you're officially fluent in gpioths πŸ’…

β€” this page came from the Debian manual set, dated December 8, 2019 β€” mwah, love u, go read your sensors πŸ“πŸ¦‹

πŸ“¦ where this page comes from