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.cpp	Sun Feb 15 02:09:00 2015 +0000
+++ b/Dht11.cpp	Mon Feb 16 01:43:08 2015 +0000
@@ -1,16 +1,15 @@
 #include "Dht11.h"
 
-Dht11::Dht11(PinName p) : _pin(p) {
+Dht11::Dht11(PinName const &p) : _pin(p) {
     // Set creation time so we can make 
     // sure we pause at least 1 second for 
     // startup.
     _timer.start();
+    
+    _temperature = 0;
+    _humidity = 0;
 }
 
-// Return values:
-// DHTLIB_OK
-// DHTLIB_ERROR_CHECKSUM
-// DHTLIB_ERROR_TIMEOUT
 int Dht11::read()
 {
     // BUFFER TO RECEIVE
@@ -77,10 +76,14 @@
     return DHTLIB_OK;
 }
 
-int Dht11::temperature() {
+float Dht11::getFahrenheit() {
+    return((_temperature * 1.8) + 32);
+}
+
+int Dht11::getCelsius() {
     return(_temperature);
 }
 
-int Dht11::humidity() {
+int Dht11::getHumidity() {
     return(_humidity);
 }