Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef MBED_DHT_H
00034 #define MBED_DHT_H
00035
00036 #include "mbed.h"
00037
00038 enum eType
00039 {
00040 DHT11 = 11,
00041 SEN11301P = 11,
00042 RHT01 = 11,
00043 DHT22 = 22,
00044 AM2302 = 22,
00045 SEN51035P = 22,
00046 RHT02 = 22,
00047 RHT03 = 22
00048 };
00049 typedef enum eType eType;
00050
00051 enum eError
00052 {
00053 ERROR_NONE = 0,
00054 BUS_BUSY,
00055 ERROR_NOT_PRESENT,
00056 ERROR_ACK_TOO_LONG,
00057 ERROR_SYNC_TIMEOUT,
00058 ERROR_DATA_TIMEOUT,
00059 ERROR_CHECKSUM,
00060 ERROR_NO_PATIENCE
00061 };
00062 typedef enum eError eError;
00063
00064 enum eScale
00065 {
00066 CELCIUS = 0,
00067 FARENHEIT,
00068 KELVIN
00069 };
00070 typedef enum eScale eScale;
00071
00072
00073 class DHT
00074 {
00075
00076 public:
00077
00078 DHT(PinName pin, eType DHTtype);
00079 ~DHT();
00080 eError readData(void);
00081 float ReadHumidity(void);
00082 float ReadTemperature(eScale const Scale);
00083 float CalcdewPoint(float const celsius, float const humidity);
00084 float CalcdewPointFast(float const celsius, float const humidity);
00085
00086 private:
00087 time_t _lastReadTime;
00088 float _lastTemperature;
00089 float _lastHumidity;
00090 PinName _pin;
00091 bool _firsttime;
00092 eType _DHTtype;
00093 uint8_t DHT_data[5];
00094 float CalcTemperature();
00095 float CalcHumidity();
00096 float ConvertCelciustoFarenheit(float const);
00097 float ConvertCelciustoKelvin(float const);
00098 eError stall(DigitalInOut &io, int const level, int const max_time);
00099
00100 };
00101
00102 #endif