In float DHT::CalcTemperature() method switch cases has been interchanged

Dependents:   esp8266_http_POST

Fork of DHT by Wim De Roeve

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers DHT.h Source File

DHT.h

00001 /* 
00002  *  DHT Library for  Digital-output Humidity and Temperature sensors 
00003  *  
00004  *  Works with DHT11, DHT21, DHT22
00005  *             SEN11301P,  Grove - Temperature&Humidity Sensor     (Seeed Studio)
00006  *             SEN51035P,  Grove - Temperature&Humidity Sensor Pro (Seeed Studio)
00007  *             AM2302   ,  temperature-humidity sensor    
00008  *             RHT01,RHT02, RHT03    ,  Humidity and Temperature Sensor         (Sparkfun)
00009  *
00010  *  Copyright (C) Wim De Roeve
00011  *                based on DHT22 sensor library by HO WING KIT
00012  *                Arduino DHT11 library
00013  *
00014  * Permission is hereby granted, free of charge, to any person obtaining a copy
00015  * of this software and associated documnetation files (the "Software"), to deal
00016  * in the Software without restriction, including without limitation the rights
00017  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00018  * copies of the Software, and to permit persons to  whom the Software is
00019  * furished to do so, subject to the following conditions:
00020  *
00021  * The above copyright notice and this permission notice shall be included in
00022  * all copies or substantial portions of the Software.
00023  *
00024  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00025  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00026  * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00027  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00028  * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00029  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00030  * THE SOFTWARE.
00031  */
00032 
00033 #ifndef MBED_DHT_H
00034 #define MBED_DHT_H
00035 
00036 #include "mbed.h"
00037 
00038 enum eType{
00039         DHT11     = 11,
00040         SEN11301P = 11,
00041         RHT01     = 11,
00042         DHT22     = 22,
00043         AM2302    = 22,
00044         SEN51035P = 22,
00045         RHT02     = 22,
00046         RHT03     = 22
00047     } ;
00048 
00049 enum eError {
00050     ERROR_NONE = 0,
00051     BUS_BUSY =1,
00052     ERROR_NOT_PRESENT =2 ,
00053     ERROR_ACK_TOO_LONG =3 ,
00054     ERROR_SYNC_TIMEOUT = 4,
00055     ERROR_DATA_TIMEOUT =5 ,
00056     ERROR_CHECKSUM = 6,
00057     ERROR_NO_PATIENCE =7
00058 } ;
00059 
00060 typedef enum {
00061     CELCIUS =0 ,
00062     FARENHEIT =1,
00063     KELVIN=2
00064 } eScale;
00065 
00066 
00067 class DHT {
00068 
00069 public:
00070 
00071     DHT(PinName pin,int DHTtype);
00072     ~DHT();
00073     int readData(void);
00074     float ReadHumidity(void);
00075     float ReadTemperature(eScale Scale);
00076     float CalcdewPoint(float celsius, float humidity);
00077     float CalcdewPointFast(float celsius, float humidity);
00078 
00079 private:
00080     time_t  _lastReadTime;
00081     float _lastTemperature;
00082     float _lastHumidity;
00083     PinName _pin;
00084     bool _firsttime;
00085     int _DHTtype;
00086     int DHT_data[6];
00087     float CalcTemperature();
00088     float CalcHumidity();
00089     float ConvertCelciustoFarenheit(float);
00090     float ConvertCelciustoKelvin(float);
00091 
00092 };
00093 
00094 #endif