Modified

Dependents:   DHT-11Mine

Fork of DHT by Wim De Roeve

Committer:
umairaftab
Date:
Tue Mar 18 23:48:19 2014 +0000
Revision:
1:21dc04090457
Parent:
0:9b5b3200688f
Working;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
umairaftab 1:21dc04090457 1
Wimpie 0:9b5b3200688f 2
Wimpie 0:9b5b3200688f 3 #ifndef MBED_DHT_H
Wimpie 0:9b5b3200688f 4 #define MBED_DHT_H
Wimpie 0:9b5b3200688f 5
Wimpie 0:9b5b3200688f 6 #include "mbed.h"
Wimpie 0:9b5b3200688f 7
Wimpie 0:9b5b3200688f 8 enum eType{
Wimpie 0:9b5b3200688f 9 DHT11 = 11,
Wimpie 0:9b5b3200688f 10 SEN11301P = 11,
Wimpie 0:9b5b3200688f 11 RHT01 = 11,
Wimpie 0:9b5b3200688f 12 DHT22 = 22,
Wimpie 0:9b5b3200688f 13 AM2302 = 22,
Wimpie 0:9b5b3200688f 14 SEN51035P = 22,
Wimpie 0:9b5b3200688f 15 RHT02 = 22,
Wimpie 0:9b5b3200688f 16 RHT03 = 22
Wimpie 0:9b5b3200688f 17 } ;
Wimpie 0:9b5b3200688f 18
Wimpie 0:9b5b3200688f 19 enum eError {
Wimpie 0:9b5b3200688f 20 ERROR_NONE = 0,
Wimpie 0:9b5b3200688f 21 BUS_BUSY =1,
Wimpie 0:9b5b3200688f 22 ERROR_NOT_PRESENT =2 ,
Wimpie 0:9b5b3200688f 23 ERROR_ACK_TOO_LONG =3 ,
Wimpie 0:9b5b3200688f 24 ERROR_SYNC_TIMEOUT = 4,
Wimpie 0:9b5b3200688f 25 ERROR_DATA_TIMEOUT =5 ,
Wimpie 0:9b5b3200688f 26 ERROR_CHECKSUM = 6,
Wimpie 0:9b5b3200688f 27 ERROR_NO_PATIENCE =7
Wimpie 0:9b5b3200688f 28 } ;
Wimpie 0:9b5b3200688f 29
Wimpie 0:9b5b3200688f 30 typedef enum {
Wimpie 0:9b5b3200688f 31 CELCIUS =0 ,
Wimpie 0:9b5b3200688f 32 FARENHEIT =1,
Wimpie 0:9b5b3200688f 33 KELVIN=2
Wimpie 0:9b5b3200688f 34 } eScale;
Wimpie 0:9b5b3200688f 35
Wimpie 0:9b5b3200688f 36
Wimpie 0:9b5b3200688f 37 class DHT {
Wimpie 0:9b5b3200688f 38
Wimpie 0:9b5b3200688f 39 public:
Wimpie 0:9b5b3200688f 40
Wimpie 0:9b5b3200688f 41 DHT(PinName pin,int DHTtype);
Wimpie 0:9b5b3200688f 42 ~DHT();
Wimpie 0:9b5b3200688f 43 int readData(void);
Wimpie 0:9b5b3200688f 44 float ReadHumidity(void);
Wimpie 0:9b5b3200688f 45 float ReadTemperature(eScale Scale);
Wimpie 0:9b5b3200688f 46 float CalcdewPoint(float celsius, float humidity);
Wimpie 0:9b5b3200688f 47 float CalcdewPointFast(float celsius, float humidity);
Wimpie 0:9b5b3200688f 48
Wimpie 0:9b5b3200688f 49 private:
Wimpie 0:9b5b3200688f 50 time_t _lastReadTime;
Wimpie 0:9b5b3200688f 51 float _lastTemperature;
Wimpie 0:9b5b3200688f 52 float _lastHumidity;
Wimpie 0:9b5b3200688f 53 PinName _pin;
Wimpie 0:9b5b3200688f 54 bool _firsttime;
Wimpie 0:9b5b3200688f 55 int _DHTtype;
Wimpie 0:9b5b3200688f 56 int DHT_data[6];
Wimpie 0:9b5b3200688f 57 float CalcTemperature();
Wimpie 0:9b5b3200688f 58 float CalcHumidity();
Wimpie 0:9b5b3200688f 59 float ConvertCelciustoFarenheit(float);
Wimpie 0:9b5b3200688f 60 float ConvertCelciustoKelvin(float);
Wimpie 0:9b5b3200688f 61
Wimpie 0:9b5b3200688f 62 };
Wimpie 0:9b5b3200688f 63
Wimpie 0:9b5b3200688f 64 #endif