Arduino-DHT
Digital Humidity and Temperature (DHT) Sensor library for Arduino
DHT< DATA_PIN, DEVICE > Class Template Reference

#include <DHT.h>

Inheritance diagram for DHT< DATA_PIN, DEVICE >:
Inheritance graph
Collaboration diagram for DHT< DATA_PIN, DEVICE >:
Collaboration graph

Public Member Functions

 DHT ()
 
float humidity ()
 
float temperature ()
 
int read (float &humidity, float &temperature)
 

Protected Attributes

GPIO< DATA_PIN > m_data
 
float m_humidity
 
float m_temperature
 

Static Protected Attributes

static const uint16_t START_SIGNAL = 18
 
static const uint16_t PULLUP = 4
 
static const int THRESHOLD = 60
 

Detailed Description

template<BOARD::pin_t DATA_PIN, uint8_t DEVICE>
class DHT< DATA_PIN, DEVICE >

DHT Humidity & Temperature Sensor device driver template class.

Parameters
[in]DATA_PINboard pin for data signal.
[in]DEVICEtype number (11, 21 or 22).

Circuit

DHTXX
+------------+
(VCC)---------------1-|VCC ====== |
(DATA_PIN)----------2-|DATA ====== |
3-| ====== |
(GND)---------------4-|GND ====== |
+------------+

Connect DHT to data pin, VCC and ground. A pullup resistor from the pin to VCC should be used. Most DHT modules have a built-in pullup resistor.

Definition at line 43 of file DHT.h.

Constructor & Destructor Documentation

template<BOARD::pin_t DATA_PIN, uint8_t DEVICE>
DHT< DATA_PIN, DEVICE >::DHT ( )
inline

Initiate device communication pin.

Definition at line 48 of file DHT.h.

Member Function Documentation

template<BOARD::pin_t DATA_PIN, uint8_t DEVICE>
float DHT< DATA_PIN, DEVICE >::humidity ( )
inline

Return latest humidity reading.

Returns
humidity.

Definition at line 59 of file DHT.h.

template<BOARD::pin_t DATA_PIN, uint8_t DEVICE>
int DHT< DATA_PIN, DEVICE >::read ( float &  humidity,
float &  temperature 
)
inline

Read humidity and temperature from device. Returns number of changed values (0-2) otherwise negative error code (-1: check sum error, -2: response pulse error)

Definition at line 78 of file DHT.h.

template<BOARD::pin_t DATA_PIN, uint8_t DEVICE>
float DHT< DATA_PIN, DEVICE >::temperature ( )
inline

Return latest temperature reading.

Returns
temperature.

Definition at line 68 of file DHT.h.

Member Data Documentation

template<BOARD::pin_t DATA_PIN, uint8_t DEVICE>
GPIO<DATA_PIN> DHT< DATA_PIN, DEVICE >::m_data
protected

Board pin for data communication.

Definition at line 140 of file DHT.h.

template<BOARD::pin_t DATA_PIN, uint8_t DEVICE>
float DHT< DATA_PIN, DEVICE >::m_humidity
protected

Latest humidity reading.

Definition at line 143 of file DHT.h.

template<BOARD::pin_t DATA_PIN, uint8_t DEVICE>
float DHT< DATA_PIN, DEVICE >::m_temperature
protected

Latest temperature reading.

Definition at line 146 of file DHT.h.

template<BOARD::pin_t DATA_PIN, uint8_t DEVICE>
const uint16_t DHT< DATA_PIN, DEVICE >::PULLUP = 4
staticprotected

Pullup delay in microseconds.

Definition at line 134 of file DHT.h.

template<BOARD::pin_t DATA_PIN, uint8_t DEVICE>
const uint16_t DHT< DATA_PIN, DEVICE >::START_SIGNAL = 18
staticprotected

Start signal pulse width in milliseconds.

Definition at line 131 of file DHT.h.

template<BOARD::pin_t DATA_PIN, uint8_t DEVICE>
const int DHT< DATA_PIN, DEVICE >::THRESHOLD = 60
staticprotected

Pulse threshold in microseconds.

Definition at line 137 of file DHT.h.


The documentation for this class was generated from the following file: