src
examples
GroveTemperatureHumidity
DHT
DHT.h
Go to the documentation of this file.
1
/*
2
* DHT Library for Digital-output Humidity and Temperature sensors
3
*
4
* Works with DHT11, DHT21, DHT22
5
* SEN11301P, Grove - Temperature&Humidity Sensor (Seeed Studio)
6
* SEN51035P, Grove - Temperature&Humidity Sensor Pro (Seeed Studio)
7
* AM2302 , temperature-humidity sensor
8
* RHT01,RHT02, RHT03 , Humidity and Temperature Sensor (Sparkfun)
9
*
10
* Copyright (C) Wim De Roeve
11
* based on DHT22 sensor library by HO WING KIT
12
* Arduino DHT11 library
13
*
14
* Permission is hereby granted, free of charge, to any person obtaining a copy
15
* of this software and associated documnetation files (the "Software"), to deal
16
* in the Software without restriction, including without limitation the rights
17
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
* copies of the Software, and to permit persons to whom the Software is
19
* furished to do so, subject to the following conditions:
20
*
21
* The above copyright notice and this permission notice shall be included in
22
* all copies or substantial portions of the Software.
23
*
24
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
* FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
* LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30
* THE SOFTWARE.
31
*/
32
33
#ifndef MBED_DHT_H
34
#define MBED_DHT_H
35
36
#include "mbed.h"
37
38
enum
eType
39
{
40
DHT11
= 11,
41
SEN11301P
= 11,
42
RHT01
= 11,
43
DHT22
= 22,
44
AM2302
= 22,
45
SEN51035P
= 22,
46
RHT02
= 22,
47
RHT03
= 22
48
};
49
typedef
enum
eType
eType
;
50
51
enum
eError
52
{
53
ERROR_NONE
= 0,
54
BUS_BUSY
,
55
ERROR_NOT_PRESENT
,
56
ERROR_ACK_TOO_LONG
,
57
ERROR_SYNC_TIMEOUT
,
58
ERROR_DATA_TIMEOUT
,
59
ERROR_CHECKSUM
,
60
ERROR_NO_PATIENCE
61
};
62
typedef
enum
eError
eError
;
63
64
enum
eScale
65
{
66
CELCIUS
= 0,
67
FARENHEIT
,
68
KELVIN
69
};
70
typedef
enum
eScale
eScale
;
71
72
73
class
DHT
74
{
75
76
public
:
77
78
DHT
(PinName pin,
eType
DHTtype);
79
~DHT
();
80
eError
readData
(
void
);
81
float
ReadHumidity
(
void
);
82
float
ReadTemperature
(
eScale
const
Scale);
83
float
CalcdewPoint
(
float
const
celsius,
float
const
humidity);
84
float
CalcdewPointFast
(
float
const
celsius,
float
const
humidity);
85
86
private
:
87
time_t
_lastReadTime
;
88
float
_lastTemperature
;
89
float
_lastHumidity
;
90
PinName
_pin
;
91
bool
_firsttime
;
92
eType
_DHTtype
;
93
uint8_t
DHT_data
[5];
94
float
CalcTemperature
();
95
float
CalcHumidity
();
96
float
ConvertCelciustoFarenheit
(
float
const
);
97
float
ConvertCelciustoKelvin
(
float
const
);
98
eError
stall
(DigitalInOut &io,
int
const
level,
int
const
max_time);
99
100
};
101
102
#endif
SEN51035P
@ SEN51035P
Definition:
DHT.h:45
DHT::_firsttime
bool _firsttime
Definition:
DHT.h:91
DHT::CalcTemperature
float CalcTemperature()
Definition:
DHT.cpp:153
DHT::ConvertCelciustoKelvin
float ConvertCelciustoKelvin(float const)
Definition:
DHT.cpp:184
DHT::ReadTemperature
float ReadTemperature(eScale const Scale)
Definition:
DHT.cpp:216
ERROR_ACK_TOO_LONG
@ ERROR_ACK_TOO_LONG
Definition:
DHT.h:56
DHT::DHT
DHT(PinName pin, eType DHTtype)
Definition:
DHT.cpp:37
BUS_BUSY
@ BUS_BUSY
Definition:
DHT.h:54
DHT::_lastTemperature
float _lastTemperature
Definition:
DHT.h:88
DHT::_pin
PinName _pin
Definition:
DHT.h:90
ERROR_NONE
@ ERROR_NONE
Definition:
DHT.h:53
eType
eType
Definition:
DHT.h:38
DHT22
@ DHT22
Definition:
DHT.h:43
DHT::_lastReadTime
time_t _lastReadTime
Definition:
DHT.h:87
DHT::CalcHumidity
float CalcHumidity()
Definition:
DHT.cpp:226
ERROR_NO_PATIENCE
@ ERROR_NO_PATIENCE
Definition:
DHT.h:60
KELVIN
@ KELVIN
Definition:
DHT.h:68
DHT::CalcdewPointFast
float CalcdewPointFast(float const celsius, float const humidity)
Definition:
DHT.cpp:207
DHT::CalcdewPoint
float CalcdewPoint(float const celsius, float const humidity)
Definition:
DHT.cpp:191
DHT::ReadHumidity
float ReadHumidity(void)
Definition:
DHT.cpp:174
eScale
eScale
Definition:
DHT.h:64
DHT::~DHT
~DHT()
Definition:
DHT.cpp:44
DHT::_DHTtype
eType _DHTtype
Definition:
DHT.h:92
ERROR_CHECKSUM
@ ERROR_CHECKSUM
Definition:
DHT.h:59
ERROR_SYNC_TIMEOUT
@ ERROR_SYNC_TIMEOUT
Definition:
DHT.h:57
ERROR_NOT_PRESENT
@ ERROR_NOT_PRESENT
Definition:
DHT.h:55
RHT03
@ RHT03
Definition:
DHT.h:47
DHT::ConvertCelciustoFarenheit
float ConvertCelciustoFarenheit(float const)
Definition:
DHT.cpp:179
DHT::_lastHumidity
float _lastHumidity
Definition:
DHT.h:89
RHT01
@ RHT01
Definition:
DHT.h:42
eError
eError
Definition:
DHT.h:51
DHT
Definition:
DHT.h:73
DHT::DHT_data
uint8_t DHT_data[5]
Definition:
DHT.h:93
DHT::stall
eError stall(DigitalInOut &io, int const level, int const max_time)
Definition:
DHT.cpp:49
SEN11301P
@ SEN11301P
Definition:
DHT.h:41
RHT02
@ RHT02
Definition:
DHT.h:46
DHT::readData
eError readData(void)
Definition:
DHT.cpp:64
ERROR_DATA_TIMEOUT
@ ERROR_DATA_TIMEOUT
Definition:
DHT.h:58
CELCIUS
@ CELCIUS
Definition:
DHT.h:66
AM2302
@ AM2302
Definition:
DHT.h:44
FARENHEIT
@ FARENHEIT
Definition:
DHT.h:67
DHT11
@ DHT11
Definition:
DHT.h:40
rosserial_mbed
Author(s): Gary Servin
autogenerated on Wed Mar 2 2022 00:58:08