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
RHT03.h@3:21ede1fe79b7, 2012-08-29 (annotated)
- Committer:
- tristanjph
- Date:
- Wed Aug 29 10:19:33 2012 +0000
- Revision:
- 3:21ede1fe79b7
- Parent:
- 2:b07365121071
- Child:
- 4:e9fe691122c1
documentation updates;
Who changed what in which revision?
User | Revision | Line number | New 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 | 3:21ede1fe79b7 | 42 | /** RHT03 interface class for reading data from the sensor */ |
tristanjph | 2:b07365121071 | 43 | class RHT03 |
tristanjph | 2:b07365121071 | 44 | { |
tristanjph | 1:2bd5cffd60d0 | 45 | private: |
tristanjph | 1:2bd5cffd60d0 | 46 | time_t _lastReadTime; |
tristanjph | 1:2bd5cffd60d0 | 47 | PinName _data; |
tristanjph | 1:2bd5cffd60d0 | 48 | float _lastHumidity; |
tristanjph | 1:2bd5cffd60d0 | 49 | float _lastTemperature; |
tristanjph | 1:2bd5cffd60d0 | 50 | public: |
tristanjph | 2:b07365121071 | 51 | /** Configure data pin |
tristanjph | 2:b07365121071 | 52 | * @param Data The data pin the RHT03 is attached to |
tristanjph | 2:b07365121071 | 53 | */ |
tristanjph | 1:2bd5cffd60d0 | 54 | RHT03(PinName Data); |
tristanjph | 1:2bd5cffd60d0 | 55 | ~RHT03(); |
tristanjph | 2:b07365121071 | 56 | /** Reads data from the RHT03 |
tristanjph | 2:b07365121071 | 57 | * @return error type or successful read |
tristanjph | 2:b07365121071 | 58 | */ |
tristanjph | 1:2bd5cffd60d0 | 59 | RHT03_ERROR readData(void); |
tristanjph | 2:b07365121071 | 60 | /** Gives current humidity value |
tristanjph | 2:b07365121071 | 61 | * @return humidity value |
tristanjph | 2:b07365121071 | 62 | */ |
tristanjph | 1:2bd5cffd60d0 | 63 | float getHumidity(); |
tristanjph | 2:b07365121071 | 64 | /** Gives current temperature value |
tristanjph | 2:b07365121071 | 65 | * @return temperature value |
tristanjph | 2:b07365121071 | 66 | */ |
tristanjph | 1:2bd5cffd60d0 | 67 | float getTemperatureC(); |
tristanjph | 1:2bd5cffd60d0 | 68 | void clockReset(); |
tristanjph | 1:2bd5cffd60d0 | 69 | }; |
tristanjph | 1:2bd5cffd60d0 | 70 | |
tristanjph | 1:2bd5cffd60d0 | 71 | #endif /*_RHT03_H_*/ |