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:
Wed Aug 29 10:16:53 2012 +0000
Revision:
2:b07365121071
Parent:
1:2bd5cffd60d0
Child:
3:21ede1fe79b7
Added documentation

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tristanjph 1:2bd5cffd60d0 1 /* mbed RHT03 Library
tristanjph 1:2bd5cffd60d0 2 * Copyright (c) 2011, sford, http://mbed.org
tristanjph 1:2bd5cffd60d0 3 *
tristanjph 1:2bd5cffd60d0 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
tristanjph 1:2bd5cffd60d0 5 * of this software and associated documnetation files (the "Software"), to deal
tristanjph 1:2bd5cffd60d0 6 * in the Software without restriction, including without limitation the rights
tristanjph 1:2bd5cffd60d0 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
tristanjph 1:2bd5cffd60d0 8 * copies of the Software, and to permit persons to whom the Software is
tristanjph 1:2bd5cffd60d0 9 * furished to do so, subject to the following conditions:
tristanjph 1:2bd5cffd60d0 10 *
tristanjph 1:2bd5cffd60d0 11 * The above copyright notice and this permission notice shall be included in
tristanjph 1:2bd5cffd60d0 12 * all copies or substantial portions of the Software.
tristanjph 1:2bd5cffd60d0 13 *
tristanjph 1:2bd5cffd60d0 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
tristanjph 1:2bd5cffd60d0 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
tristanjph 1:2bd5cffd60d0 16 * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
tristanjph 1:2bd5cffd60d0 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
tristanjph 1:2bd5cffd60d0 18 * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
tristanjph 1:2bd5cffd60d0 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
tristanjph 1:2bd5cffd60d0 20 * THE SOFTWARE.
tristanjph 1:2bd5cffd60d0 21 */
tristanjph 1:2bd5cffd60d0 22
tristanjph 1:2bd5cffd60d0 23 #ifndef MBED_RHT03_H
tristanjph 1:2bd5cffd60d0 24 #define MBED_RHT03_H
tristanjph 1:2bd5cffd60d0 25
tristanjph 1:2bd5cffd60d0 26 #include "mbed.h"
tristanjph 1:2bd5cffd60d0 27
tristanjph 1:2bd5cffd60d0 28
tristanjph 1:2bd5cffd60d0 29 #define RHT03_ERROR_VALUE -99.5
tristanjph 1:2bd5cffd60d0 30
tristanjph 1:2bd5cffd60d0 31 typedef enum {
tristanjph 1:2bd5cffd60d0 32 RHT_ERROR_NONE = 0,
tristanjph 1:2bd5cffd60d0 33 RHT_BUS_HUNG,
tristanjph 1:2bd5cffd60d0 34 RHT_ERROR_NOT_PRESENT,
tristanjph 1:2bd5cffd60d0 35 RHT_ERROR_ACK_TOO_LONG,
tristanjph 1:2bd5cffd60d0 36 RHT_ERROR_SYNC_TIMEOUT,
tristanjph 1:2bd5cffd60d0 37 RHT_ERROR_DATA_TIMEOUT,
tristanjph 1:2bd5cffd60d0 38 RHT_ERROR_CHECKSUM,
tristanjph 1:2bd5cffd60d0 39 RHT_ERROR_TOO_QUICK
tristanjph 1:2bd5cffd60d0 40 } RHT03_ERROR;
tristanjph 1:2bd5cffd60d0 41
tristanjph 2:b07365121071 42 class RHT03
tristanjph 2:b07365121071 43 {
tristanjph 1:2bd5cffd60d0 44 private:
tristanjph 1:2bd5cffd60d0 45 time_t _lastReadTime;
tristanjph 1:2bd5cffd60d0 46 PinName _data;
tristanjph 1:2bd5cffd60d0 47 float _lastHumidity;
tristanjph 1:2bd5cffd60d0 48 float _lastTemperature;
tristanjph 1:2bd5cffd60d0 49 public:
tristanjph 2:b07365121071 50 /** Configure data pin
tristanjph 2:b07365121071 51 * @param Data The data pin the RHT03 is attached to
tristanjph 2:b07365121071 52 */
tristanjph 1:2bd5cffd60d0 53 RHT03(PinName Data);
tristanjph 1:2bd5cffd60d0 54 ~RHT03();
tristanjph 2:b07365121071 55 /** Reads data from the RHT03
tristanjph 2:b07365121071 56 * @return error type or successful read
tristanjph 2:b07365121071 57 */
tristanjph 1:2bd5cffd60d0 58 RHT03_ERROR readData(void);
tristanjph 2:b07365121071 59 /** Gives current humidity value
tristanjph 2:b07365121071 60 * @return humidity value
tristanjph 2:b07365121071 61 */
tristanjph 1:2bd5cffd60d0 62 float getHumidity();
tristanjph 2:b07365121071 63 /** Gives current temperature value
tristanjph 2:b07365121071 64 * @return temperature value
tristanjph 2:b07365121071 65 */
tristanjph 1:2bd5cffd60d0 66 float getTemperatureC();
tristanjph 1:2bd5cffd60d0 67 void clockReset();
tristanjph 1:2bd5cffd60d0 68 };
tristanjph 1:2bd5cffd60d0 69
tristanjph 1:2bd5cffd60d0 70 #endif /*_RHT03_H_*/