DHT.h
Go to the documentation of this file.
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 {
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


rosserial_mbed
Author(s): Gary Servin
autogenerated on Sat Oct 7 2017 03:08:46