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 "periph/gpio.h"
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
42 enum {
43  DHT_OK = 0,
44  DHT_NOCSUM = -1,
45  DHT_NODEV = -2
46 };
47 
51 typedef struct {
52  uint16_t humidity;
53  uint16_t temperature;
54 } dht_data_t;
55 
59 typedef enum {
63 } dht_type_t;
64 
68 typedef struct {
69  gpio_t pin;
70  dht_type_t type;
73 } dht_t;
74 
79 
89 int dht_init(dht_t *dev, const dht_params_t *params);
90 
105 int dht_read(const dht_t *dev, int16_t *temp, int16_t *hum);
106 
107 #ifdef __cplusplus
108 }
109 #endif
110 
111 #endif /* DHT_H */
112 
DHT22 device identifier.
Definition: dht.h:61
dht_t dht_params_t
Configuration parameters for DHT devices.
Definition: dht.h:78
checksum error
Definition: dht.h:44
Low-level GPIO peripheral driver interface definitions.
dht_type_t
Device type of the DHT device.
Definition: dht.h:59
DHT21 device identifier.
Definition: dht.h:62
device type not defined
Definition: dht.h:45
all good
Definition: dht.h:43
gpio_t pin
GPIO pin of the device&#39;s data pin.
Definition: dht.h:69
int dht_init(dht_t *dev, const dht_params_t *params)
Initialize a new DHT device.
gpio_mode_t in_mode
input pin configuration, with or without pull resistor
Definition: dht.h:71
uint16_t temperature
temperature in deca-Celsius
Definition: dht.h:53
Data type for storing DHT sensor readings.
Definition: dht.h:51
DHT11 device identifier.
Definition: dht.h:60
dht_type_t type
type of the DHT device
Definition: dht.h:70
int dht_read(const dht_t *dev, int16_t *temp, int16_t *hum)
get a new temperature and humidity value from the device
uint16_t humidity
relative deca-humidity
Definition: dht.h:52
Device descriptor for DHT sensor devices.
Definition: dht.h:68