Version Beta para la FRDM-KL46Z del original de Arduino Uno

Dependencies:   mbed TextLCD

Committer:
RazielLopez
Date:
Wed Jan 16 01:47:15 2019 +0000
Revision:
17:4f5b8e228f4a
Parent:
15:c0bb10aadebc
Counting and ready for first release .... TEAM T says hello to the world for the first time

Who changed what in which revision?

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