needs more commenting, log file errors, LED feedback

Dependencies:   ARCH_GPRS_V2_HW Blinker GPRSInterface HTTPClient_GPRS RTC_WorkingLibrary SDFileSystem USBDevice mbed

Fork of finalv2 by Cellular building monitoring

Committer:
mbotkinl
Date:
Fri May 08 14:57:00 2015 +0000
Revision:
5:96d91bbd6c14
Parent:
0:77d82c39b97c
Final working version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbotkinl 0:77d82c39b97c 1 /*
mbotkinl 0:77d82c39b97c 2 * DHT Library for Digital-output Humidity and Temperature sensors
mbotkinl 0:77d82c39b97c 3 *
mbotkinl 0:77d82c39b97c 4 * Works with DHT11, DHT21, DHT22
mbotkinl 0:77d82c39b97c 5 * SEN11301P, Grove - Temperature&Humidity Sensor (Seeed Studio)
mbotkinl 0:77d82c39b97c 6 * SEN51035P, Grove - Temperature&Humidity Sensor Pro (Seeed Studio)
mbotkinl 0:77d82c39b97c 7 * AM2302 , temperature-humidity sensor
mbotkinl 0:77d82c39b97c 8 * RHT01,RHT02, RHT03 , Humidity and Temperature Sensor (Sparkfun)
mbotkinl 0:77d82c39b97c 9 *
mbotkinl 0:77d82c39b97c 10 * Copyright (C) Wim De Roeve
mbotkinl 0:77d82c39b97c 11 * based on DHT22 sensor library by HO WING KIT
mbotkinl 0:77d82c39b97c 12 * Arduino DHT11 library
mbotkinl 0:77d82c39b97c 13 *
mbotkinl 0:77d82c39b97c 14 * Permission is hereby granted, free of charge, to any person obtaining a copy
mbotkinl 0:77d82c39b97c 15 * of this software and associated documnetation files (the "Software"), to deal
mbotkinl 0:77d82c39b97c 16 * in the Software without restriction, including without limitation the rights
mbotkinl 0:77d82c39b97c 17 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
mbotkinl 0:77d82c39b97c 18 * copies of the Software, and to permit persons to whom the Software is
mbotkinl 0:77d82c39b97c 19 * furished to do so, subject to the following conditions:
mbotkinl 0:77d82c39b97c 20 *
mbotkinl 0:77d82c39b97c 21 * The above copyright notice and this permission notice shall be included in
mbotkinl 0:77d82c39b97c 22 * all copies or substantial portions of the Software.
mbotkinl 0:77d82c39b97c 23 *
mbotkinl 0:77d82c39b97c 24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
mbotkinl 0:77d82c39b97c 25 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
mbotkinl 0:77d82c39b97c 26 * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
mbotkinl 0:77d82c39b97c 27 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
mbotkinl 0:77d82c39b97c 28 * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
mbotkinl 0:77d82c39b97c 29 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
mbotkinl 0:77d82c39b97c 30 * THE SOFTWARE.
mbotkinl 0:77d82c39b97c 31 */
mbotkinl 0:77d82c39b97c 32
mbotkinl 0:77d82c39b97c 33 #ifndef MBED_DHT_H
mbotkinl 0:77d82c39b97c 34 #define MBED_DHT_H
mbotkinl 0:77d82c39b97c 35
mbotkinl 0:77d82c39b97c 36 #include "mbed.h"
mbotkinl 0:77d82c39b97c 37
mbotkinl 0:77d82c39b97c 38 enum eType{
mbotkinl 0:77d82c39b97c 39 DHT11 = 11,
mbotkinl 0:77d82c39b97c 40 SEN11301P = 11,
mbotkinl 0:77d82c39b97c 41 RHT01 = 11,
mbotkinl 0:77d82c39b97c 42 DHT22 = 22,
mbotkinl 0:77d82c39b97c 43 AM2302 = 22,
mbotkinl 0:77d82c39b97c 44 SEN51035P = 22,
mbotkinl 0:77d82c39b97c 45 RHT02 = 22,
mbotkinl 0:77d82c39b97c 46 RHT03 = 22
mbotkinl 0:77d82c39b97c 47 } ;
mbotkinl 0:77d82c39b97c 48
mbotkinl 0:77d82c39b97c 49 enum eError {
mbotkinl 0:77d82c39b97c 50 ERROR_NONE = 0,
mbotkinl 0:77d82c39b97c 51 BUS_BUSY =1,
mbotkinl 0:77d82c39b97c 52 ERROR_NOT_PRESENT =2 ,
mbotkinl 0:77d82c39b97c 53 ERROR_ACK_TOO_LONG =3 ,
mbotkinl 0:77d82c39b97c 54 ERROR_SYNC_TIMEOUT = 4,
mbotkinl 0:77d82c39b97c 55 ERROR_DATA_TIMEOUT =5 ,
mbotkinl 0:77d82c39b97c 56 ERROR_CHECKSUM = 6,
mbotkinl 0:77d82c39b97c 57 ERROR_NO_PATIENCE =7
mbotkinl 0:77d82c39b97c 58 } ;
mbotkinl 0:77d82c39b97c 59
mbotkinl 0:77d82c39b97c 60 typedef enum {
mbotkinl 0:77d82c39b97c 61 CELCIUS =0 ,
mbotkinl 0:77d82c39b97c 62 FARENHEIT =1,
mbotkinl 0:77d82c39b97c 63 KELVIN=2
mbotkinl 0:77d82c39b97c 64 } eScale;
mbotkinl 0:77d82c39b97c 65
mbotkinl 0:77d82c39b97c 66
mbotkinl 0:77d82c39b97c 67 class DHT {
mbotkinl 0:77d82c39b97c 68
mbotkinl 0:77d82c39b97c 69 public:
mbotkinl 0:77d82c39b97c 70
mbotkinl 0:77d82c39b97c 71 DHT(PinName pin,int DHTtype);
mbotkinl 0:77d82c39b97c 72 ~DHT();
mbotkinl 0:77d82c39b97c 73 int readData(void);
mbotkinl 0:77d82c39b97c 74 float ReadHumidity(void);
mbotkinl 0:77d82c39b97c 75 float ReadTemperature(eScale Scale);
mbotkinl 0:77d82c39b97c 76 float CalcdewPoint(float celsius, float humidity);
mbotkinl 0:77d82c39b97c 77 float CalcdewPointFast(float celsius, float humidity);
mbotkinl 0:77d82c39b97c 78
mbotkinl 0:77d82c39b97c 79 private:
mbotkinl 0:77d82c39b97c 80 time_t _lastReadTime;
mbotkinl 0:77d82c39b97c 81 float _lastTemperature;
mbotkinl 0:77d82c39b97c 82 float _lastHumidity;
mbotkinl 0:77d82c39b97c 83 PinName _pin;
mbotkinl 0:77d82c39b97c 84 bool _firsttime;
mbotkinl 0:77d82c39b97c 85 int _DHTtype;
mbotkinl 0:77d82c39b97c 86 int DHT_data[6];
mbotkinl 0:77d82c39b97c 87 float CalcTemperature();
mbotkinl 0:77d82c39b97c 88 float CalcHumidity();
mbotkinl 0:77d82c39b97c 89 float ConvertCelciustoFarenheit(float);
mbotkinl 0:77d82c39b97c 90 float ConvertCelciustoKelvin(float);
mbotkinl 0:77d82c39b97c 91
mbotkinl 0:77d82c39b97c 92 };
mbotkinl 0:77d82c39b97c 93
mbotkinl 0:77d82c39b97c 94 #endif