DHT Family of Humidity and Temperature Sensors

Device driver for the DHT Family of humidity and temperature sensors. More...

Detailed Description

Files

file  dht.h
 Device driver interface for the DHT family of humidity and temperature sensors.
 

Data Structures

struct  dht_data_t
 data type for storing DHT sensor readings More...
 
struct  dht_t
 device descriptor for DHT sensor devices More...
 

Typedefs

typedef dht_t dht_params_t
 configuration parameters for DHT devices
 

Enumerations

enum  { DHT_OK = 0, DHT_NOCSUM = -1, DHT_NODEV = -2 }
 possible return codes More...
 
enum  dht_type_t { DHT11, DHT22, DHT21 = DHT22 }
 device type of the DHT device More...
 

Functions

void dht_auto_init (void)
 auto-initialize all configured DHT devices
 
int dht_init (dht_t *dev, const dht_params_t *params)
 initialize a new DHT device More...
 
int dht_read (const dht_t *dev, int16_t *temp, int16_t *hum)
 get a new temperature and humidity value from the device More...
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
DHT_OK 

all good

DHT_NOCSUM 

checksum error

DHT_NODEV 

device type not defined

Definition at line 42 of file dht.h.

◆ dht_type_t

enum dht_type_t
Enumerator
DHT11 

DHT11 device identifier.

DHT22 

DHT22 device identifier.

DHT21 

DHT21 device identifier.

Definition at line 59 of file dht.h.

Function Documentation

◆ dht_init()

int dht_init ( dht_t dev,
const dht_params_t params 
)
Parameters
[out]devdevice descriptor of a DHT device
[in]paramsconfiguration parameters
Returns
0 on success
-1 on error

◆ dht_read()

int dht_read ( const dht_t dev,
int16_t *  temp,
int16_t *  hum 
)
Note
if reading fails or checksum is invalid, no new values will be written into the result values
Parameters
[in]devdevice descriptor of a DHT device
[out]temptemperature value [in °C * 10^-1]
[out]humrelative humidity value [in percent * 10^-1]
Returns
0 on success
-1 on checksum error
-2 on parsing error