dht.h
Go to the documentation of this file.
1 /*
2  * Copyright 2015 Ludwig Knüpfer,
3  * 2015 Christian Mehlis
4  * 2016-2017 Freie Universität Berlin
5  *
6  * This file is subject to the terms and conditions of the GNU Lesser
7  * General Public License v2.1. See the file LICENSE in the top level
8  * directory for more details.
9  */
10 
28 #ifndef DHT_H
29 #define DHT_H
30 
31 #include <stdint.h>
32 
33 #include "saul.h"
34 #include "periph/gpio.h"
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
43 enum {
44  DHT_OK = 0,
45  DHT_NOCSUM = -1,
46  DHT_NODEV = -2
47 };
48 
52 typedef struct {
53  uint16_t humidity;
54  uint16_t temperature;
55 } dht_data_t;
56 
60 typedef enum {
64 } dht_type_t;
65 
69 typedef struct {
70  gpio_t pin;
74 } dht_t;
75 
80 
86 extern const saul_driver_t dht_hum_saul_driver;
92 void dht_auto_init(void);
93 
103 int dht_init(dht_t *dev, const dht_params_t *params);
104 
119 int dht_read(dht_t *dev, int16_t *temp, int16_t *hum);
120 
121 #ifdef __cplusplus
122 }
123 #endif
124 
125 #endif /* DHT_H */
126 
DHT22 device identifier.
Definition: dht.h:62
dht_t dht_params_t
configuration parameters for DHT devices
Definition: dht.h:79
checksum error
Definition: dht.h:45
Low-level GPIO peripheral driver interface definitions.
dht_type_t
device type of the DHT device
Definition: dht.h:60
DHT21 device identifier.
Definition: dht.h:63
int dht_read(dht_t *dev, int16_t *temp, int16_t *hum)
get a new temperature and humidity value from the device
Definition of the RIOT actuator/sensor interface.
Definition: saul.h:139
gpio_t pin
GPIO pin of the device's data pin.
Definition: dht.h:70
int dht_init(dht_t *dev, const dht_params_t *params)
initialize a new DHT device
all good
Definition: dht.h:44
Definition of the generic [S]ensor [A]ctuator [U]ber [L]ayer.
device type not defined
Definition: dht.h:46
gpio_mode_t in_mode
input pin configuration, with or without pull resistor
Definition: dht.h:72
uint16_t temperature
temperature in deca-Celsius
Definition: dht.h:54
data type for storing DHT sensor readings
Definition: dht.h:52
DHT11 device identifier.
Definition: dht.h:61
void dht_auto_init(void)
auto-initialize all configured DHT devices
dht_type_t type
type of the DHT device
Definition: dht.h:71
const saul_driver_t dht_temp_saul_driver
export SAUL endpoints
uint16_t humidity
relative deca-humidity
Definition: dht.h:53
device descriptor for DHT sensor devices
Definition: dht.h:69