My_microcontroller
Fork of DHT-11Mine by
Embed:
(wiki syntax)
Show/hide line numbers
DHT.h
00001 00002 #ifndef MBED_DHT_H 00003 #define MBED_DHT_H 00004 00005 #include "mbed.h" 00006 00007 enum eType{ 00008 DHT11 = 11, 00009 SEN11301P = 11, 00010 RHT01 = 11, 00011 } ; 00012 00013 enum eError { 00014 ERROR_NONE = 0, 00015 BUS_BUSY =1, 00016 ERROR_NOT_PRESENT =2 , 00017 ERROR_ACK_TOO_LONG =3 , 00018 ERROR_SYNC_TIMEOUT = 4, 00019 ERROR_DATA_TIMEOUT =5 , 00020 ERROR_CHECKSUM = 6, 00021 ERROR_NO_PATIENCE =7 00022 } ; 00023 00024 typedef enum { 00025 CELCIUS =0 , 00026 FARENHEIT =1, 00027 KELVIN=2 00028 } eScale; 00029 00030 00031 class DHT { 00032 00033 public: 00034 00035 DHT(PinName pin,int DHTtype); 00036 ~DHT(); 00037 int readData(void); 00038 float ReadHumidity(void); 00039 float ReadTemperature(eScale Scale); 00040 00041 00042 private: 00043 time_t _lastReadTime; 00044 float _lastTemperature; 00045 float _lastHumidity; 00046 PinName _pin; 00047 bool _firsttime; 00048 int _DHTtype; 00049 int DHT_data[6]; 00050 float CalcTemperature(); 00051 float CalcHumidity(); 00052 float ConvertCelciustoFarenheit(float); 00053 float ConvertCelciustoKelvin(float); 00054 00055 }; 00056 00057 #endif
Generated on Wed Jul 13 2022 09:49:33 by
1.7.2
