removed silly included mbed library..

Fork of DHT11 by Michael Steel

Committer:
Demonthorn
Date:
Mon Jul 10 15:20:33 2017 +0000
Revision:
2:65c4ca53154d
Parent:
1:5da6f6de3e42
Floated Variables to correct improper Centigrade readings

Who changed what in which revision?

UserRevisionLine numberNew contents of line
fossum_13 0:c1da310d3e8a 1 #ifndef DHT11_H
fossum_13 0:c1da310d3e8a 2 #define DHT11_H
fossum_13 0:c1da310d3e8a 3
fossum_13 0:c1da310d3e8a 4 #include "mbed.h"
fossum_13 0:c1da310d3e8a 5
fossum_13 0:c1da310d3e8a 6 #define DHTLIB_OK 0
fossum_13 0:c1da310d3e8a 7 #define DHTLIB_ERROR_CHECKSUM -1
fossum_13 0:c1da310d3e8a 8 #define DHTLIB_ERROR_TIMEOUT -2
fossum_13 0:c1da310d3e8a 9
fossum_13 1:5da6f6de3e42 10 /** Class for the DHT11 sensor.
fossum_13 1:5da6f6de3e42 11 *
fossum_13 1:5da6f6de3e42 12 * Example:
fossum_13 1:5da6f6de3e42 13 * @code
fossum_13 1:5da6f6de3e42 14 * #include "mbed.h"
fossum_13 1:5da6f6de3e42 15 * #include "Dht11.h"
fossum_13 1:5da6f6de3e42 16 *
fossum_13 1:5da6f6de3e42 17 * Serial pc(USBTX, USBRX);
fossum_13 1:5da6f6de3e42 18 * Dht11 sensor(PTD7);
fossum_13 1:5da6f6de3e42 19 *
fossum_13 1:5da6f6de3e42 20 * int main() {
fossum_13 1:5da6f6de3e42 21 * sensor.read()
fossum_13 1:5da6f6de3e42 22 * pc.printf("T: %f, H: %d\r\n", sensor.getFahrenheit(), sensor.getHumidity());
fossum_13 1:5da6f6de3e42 23 * }
fossum_13 1:5da6f6de3e42 24 * @endcode
fossum_13 1:5da6f6de3e42 25 */
fossum_13 1:5da6f6de3e42 26 class Dht11
fossum_13 1:5da6f6de3e42 27 {
fossum_13 0:c1da310d3e8a 28 public:
fossum_13 1:5da6f6de3e42 29 /** Construct the sensor object.
fossum_13 1:5da6f6de3e42 30 *
fossum_13 1:5da6f6de3e42 31 * @param pin PinName for the sensor pin.
fossum_13 1:5da6f6de3e42 32 */
fossum_13 1:5da6f6de3e42 33 Dht11(PinName const &p);
fossum_13 1:5da6f6de3e42 34
fossum_13 1:5da6f6de3e42 35 /** Update the humidity and temp from the sensor.
fossum_13 1:5da6f6de3e42 36 *
fossum_13 1:5da6f6de3e42 37 * @returns
fossum_13 1:5da6f6de3e42 38 * 0 on success, otherwise error.
fossum_13 1:5da6f6de3e42 39 */
fossum_13 0:c1da310d3e8a 40 int read();
fossum_13 1:5da6f6de3e42 41
fossum_13 1:5da6f6de3e42 42 /** Get the temp(f) from the saved object.
fossum_13 1:5da6f6de3e42 43 *
fossum_13 1:5da6f6de3e42 44 * @returns
fossum_13 1:5da6f6de3e42 45 * Fahrenheit float
fossum_13 1:5da6f6de3e42 46 */
fossum_13 1:5da6f6de3e42 47 float getFahrenheit();
fossum_13 0:c1da310d3e8a 48
fossum_13 1:5da6f6de3e42 49 /** Get the temp(c) from the saved object.
fossum_13 1:5da6f6de3e42 50 *
fossum_13 1:5da6f6de3e42 51 * @returns
fossum_13 1:5da6f6de3e42 52 * Celsius int
fossum_13 1:5da6f6de3e42 53 */
Demonthorn 2:65c4ca53154d 54 float getCelsius();
fossum_13 1:5da6f6de3e42 55
fossum_13 1:5da6f6de3e42 56 /** Get the humidity from the saved object.
fossum_13 1:5da6f6de3e42 57 *
fossum_13 1:5da6f6de3e42 58 * @returns
fossum_13 1:5da6f6de3e42 59 * Humidity percent int
fossum_13 1:5da6f6de3e42 60 */
Demonthorn 2:65c4ca53154d 61 float getHumidity();
fossum_13 1:5da6f6de3e42 62
fossum_13 0:c1da310d3e8a 63 private:
fossum_13 1:5da6f6de3e42 64 /// percentage of humidity
fossum_13 0:c1da310d3e8a 65 int _humidity;
fossum_13 1:5da6f6de3e42 66 /// celsius
fossum_13 0:c1da310d3e8a 67 int _temperature;
fossum_13 1:5da6f6de3e42 68 /// pin to read the sensor info on
fossum_13 0:c1da310d3e8a 69 DigitalInOut _pin;
fossum_13 1:5da6f6de3e42 70 /// times startup (must settle for at least a second)
fossum_13 0:c1da310d3e8a 71 Timer _timer;
fossum_13 0:c1da310d3e8a 72 };
fossum_13 0:c1da310d3e8a 73
fossum_13 0:c1da310d3e8a 74 #endif