Programme d'une sonde de température DHT 11 associée à de la sauvegarde de données sur clé USB et à l'affichage de ces données sur afficheur LCD

Dependencies:   FatFileSystemCpp mbed

Committer:
Fanta025
Date:
Tue Jun 02 14:19:54 2015 +0000
Revision:
0:ed0b4e66d2ad
Programme d'une sonde de temp?rature DHT 11 associ?e ? de la sauvegarde de donn?es sur USB et un affichage sur ?cran LCD

Who changed what in which revision?

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