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