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 {
61 };
62 typedef enum eError eError;
63 
64 enum eScale
65 {
66  CELCIUS = 0,
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;
90  PinName _pin;
91  bool _firsttime;
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
eError
Definition: DHT.h:51
time_t _lastReadTime
Definition: DHT.h:87
Definition: DHT.h:47
float CalcdewPoint(float const celsius, float const humidity)
Definition: DHT.cpp:191
float ReadTemperature(eScale const Scale)
Definition: DHT.cpp:216
Definition: DHT.h:46
Definition: DHT.h:66
float CalcHumidity()
Definition: DHT.cpp:226
float _lastTemperature
Definition: DHT.h:88
Definition: DHT.h:41
Definition: DHT.h:44
float CalcTemperature()
Definition: DHT.cpp:153
Definition: DHT.h:40
float _lastHumidity
Definition: DHT.h:89
Definition: DHT.h:67
Definition: DHT.h:45
~DHT()
Definition: DHT.cpp:44
float ConvertCelciustoKelvin(float const)
Definition: DHT.cpp:184
eScale
Definition: DHT.h:64
eType _DHTtype
Definition: DHT.h:92
eType
Definition: DHT.h:38
Definition: DHT.h:54
Definition: DHT.h:73
Definition: DHT.h:53
float ReadHumidity(void)
Definition: DHT.cpp:174
uint8_t DHT_data[5]
Definition: DHT.h:93
bool _firsttime
Definition: DHT.h:91
eError stall(DigitalInOut &io, int const level, int const max_time)
Definition: DHT.cpp:49
Definition: DHT.h:43
eError readData(void)
Definition: DHT.cpp:64
Definition: DHT.h:68
float CalcdewPointFast(float const celsius, float const humidity)
Definition: DHT.cpp:207
float ConvertCelciustoFarenheit(float const)
Definition: DHT.cpp:179
PinName _pin
Definition: DHT.h:90
Definition: DHT.h:42
DHT(PinName pin, eType DHTtype)
Definition: DHT.cpp:37


rosserial_mbed
Author(s): Gary Servin
autogenerated on Mon Jun 10 2019 14:53:26