A minimal library for the DHT11.

Dependencies:   mbed

Dependents:   EXP10_DHT11_LCD Sushil_MODSERIAL Core1000_SmartFarm idd_summer17_hw3_evey_jenny_seiyoung ... more

Revision:
1:5da6f6de3e42
Parent:
0:c1da310d3e8a
--- a/Dht11.h	Sun Feb 15 02:09:00 2015 +0000
+++ b/Dht11.h	Mon Feb 16 01:43:08 2015 +0000
@@ -7,17 +7,67 @@
 #define DHTLIB_ERROR_CHECKSUM   -1
 #define DHTLIB_ERROR_TIMEOUT    -2
 
-class Dht11 {
+/** Class for the DHT11 sensor.
+ * 
+ * Example:
+ * @code
+ * #include "mbed.h"
+ * #include "Dht11.h"
+ *
+ * Serial pc(USBTX, USBRX);
+ * Dht11 sensor(PTD7);
+ * 
+ * int main() {
+ *     sensor.read()
+ *     pc.printf("T: %f, H: %d\r\n", sensor.getFahrenheit(), sensor.getHumidity());
+ * }
+ * @endcode
+ */
+class Dht11
+{
 public:
-    Dht11(PinName p);
+    /** Construct the sensor object.
+     *
+     * @param pin PinName for the sensor pin.
+     */
+    Dht11(PinName const &p);
+    
+    /** Update the humidity and temp from the sensor.
+     *
+     * @returns
+     *   0 on success, otherwise error.
+     */
     int read();
-    int temperature();
-    int humidity();
+    
+    /** Get the temp(f) from the saved object.
+     *
+     * @returns
+     *   Fahrenheit float
+     */
+    float getFahrenheit();
     
+    /** Get the temp(c) from the saved object.
+     *
+     * @returns
+     *   Celsius int
+     */
+    int getCelsius();
+    
+    /** Get the humidity from the saved object.
+     *
+     * @returns
+     *   Humidity percent int
+     */
+    int getHumidity();
+
 private:
+    /// percentage of humidity
     int _humidity;
+    /// celsius
     int _temperature;
+    /// pin to read the sensor info on
     DigitalInOut _pin;
+    /// times startup (must settle for at least a second)
     Timer _timer;
 };