An eddied version of http://mbed.org/users/crazystick/code/DHT22/ for LPC11U24. All printf statements are removed and features requiring the real time clock are removed.

Dependents:   RHT03_HelloWorld IOT_sensor_nfc CanSat_Alex cansat_alex_v1 ... more

Committer:
tristanjph
Date:
Tue Aug 28 14:27:50 2012 +0000
Revision:
0:24f59e3759a1
Child:
1:2bd5cffd60d0
First commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tristanjph 0:24f59e3759a1 1 /* mbed DHT22 Library
tristanjph 0:24f59e3759a1 2 * Copyright (c) 2011, sford, http://mbed.org
tristanjph 0:24f59e3759a1 3 *
tristanjph 0:24f59e3759a1 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
tristanjph 0:24f59e3759a1 5 * of this software and associated documnetation files (the "Software"), to deal
tristanjph 0:24f59e3759a1 6 * in the Software without restriction, including without limitation the rights
tristanjph 0:24f59e3759a1 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
tristanjph 0:24f59e3759a1 8 * copies of the Software, and to permit persons to whom the Software is
tristanjph 0:24f59e3759a1 9 * furished to do so, subject to the following conditions:
tristanjph 0:24f59e3759a1 10 *
tristanjph 0:24f59e3759a1 11 * The above copyright notice and this permission notice shall be included in
tristanjph 0:24f59e3759a1 12 * all copies or substantial portions of the Software.
tristanjph 0:24f59e3759a1 13 *
tristanjph 0:24f59e3759a1 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
tristanjph 0:24f59e3759a1 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
tristanjph 0:24f59e3759a1 16 * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
tristanjph 0:24f59e3759a1 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
tristanjph 0:24f59e3759a1 18 * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
tristanjph 0:24f59e3759a1 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
tristanjph 0:24f59e3759a1 20 * THE SOFTWARE.
tristanjph 0:24f59e3759a1 21 */
tristanjph 0:24f59e3759a1 22
tristanjph 0:24f59e3759a1 23 #ifndef MBED_DHT22_H
tristanjph 0:24f59e3759a1 24 #define MBED_DHT22_H
tristanjph 0:24f59e3759a1 25
tristanjph 0:24f59e3759a1 26 #include "mbed.h"
tristanjph 0:24f59e3759a1 27
tristanjph 0:24f59e3759a1 28
tristanjph 0:24f59e3759a1 29 #define DHT22_ERROR_VALUE -99.5
tristanjph 0:24f59e3759a1 30
tristanjph 0:24f59e3759a1 31 typedef enum {
tristanjph 0:24f59e3759a1 32 DHT_ERROR_NONE = 0,
tristanjph 0:24f59e3759a1 33 DHT_BUS_HUNG,
tristanjph 0:24f59e3759a1 34 DHT_ERROR_NOT_PRESENT,
tristanjph 0:24f59e3759a1 35 DHT_ERROR_ACK_TOO_LONG,
tristanjph 0:24f59e3759a1 36 DHT_ERROR_SYNC_TIMEOUT,
tristanjph 0:24f59e3759a1 37 DHT_ERROR_DATA_TIMEOUT,
tristanjph 0:24f59e3759a1 38 DHT_ERROR_CHECKSUM,
tristanjph 0:24f59e3759a1 39 DHT_ERROR_TOO_QUICK
tristanjph 0:24f59e3759a1 40 } DHT22_ERROR;
tristanjph 0:24f59e3759a1 41
tristanjph 0:24f59e3759a1 42 class DHT22 {
tristanjph 0:24f59e3759a1 43 private:
tristanjph 0:24f59e3759a1 44 time_t _lastReadTime;
tristanjph 0:24f59e3759a1 45 PinName _data;
tristanjph 0:24f59e3759a1 46 float _lastHumidity;
tristanjph 0:24f59e3759a1 47 float _lastTemperature;
tristanjph 0:24f59e3759a1 48 public:
tristanjph 0:24f59e3759a1 49 DHT22(PinName Data);
tristanjph 0:24f59e3759a1 50 ~DHT22();
tristanjph 0:24f59e3759a1 51 DHT22_ERROR readData(void);
tristanjph 0:24f59e3759a1 52 float getHumidity();
tristanjph 0:24f59e3759a1 53 float getTemperatureC();
tristanjph 0:24f59e3759a1 54 void clockReset();
tristanjph 0:24f59e3759a1 55 };
tristanjph 0:24f59e3759a1 56
tristanjph 0:24f59e3759a1 57 #endif /*_DHT22_H_*/