Library for the control of the DHT22.

Dependents:   Interfacage_Disco_DHT22

Files at this revision

API Documentation at this revision

Comitter:
dacamposol
Date:
Thu Apr 16 12:00:14 2020 +0000
Parent:
1:3385bd532812
Commit message:
Increase the detail on the temperature and humidity (float accuracy)

Changed in this revision

DHT22.cpp Show annotated file Show diff for this revision Revisions of this file
DHT22.h Show annotated file Show diff for this revision Revisions of this file
--- a/DHT22.cpp	Thu Apr 16 08:55:38 2020 +0000
+++ b/DHT22.cpp	Thu Apr 16 12:00:14 2020 +0000
@@ -7,6 +7,7 @@
     DigitalInOut dht(pin_name);
     dht.output();
     dht.write(1);
+    thread_sleep_for(2);
 }
 
 short DHT22::shortFromBits(bool bits[])
@@ -101,12 +102,12 @@
     return 1;
 }
 
-int DHT22::getTemperature()
+float DHT22::getTemperature()
 {
     return m_temperature;
 }
 
-int DHT22::getHumidity()
+float DHT22::getHumidity()
 {
     return m_humidity;
 }
\ No newline at end of file
--- a/DHT22.h	Thu Apr 16 08:55:38 2020 +0000
+++ b/DHT22.h	Thu Apr 16 12:00:14 2020 +0000
@@ -7,7 +7,7 @@
 {
 private:
     PinName pin_name;
-    int m_temperature, m_humidity;
+    float m_temperature, m_humidity;
     
     short shortFromBits(bool bits[]);
 
@@ -25,12 +25,12 @@
     /* Returns the value of the temperature captured by the sensor
      * - PRE: The method read() has been performed at least once.
      */
-    int getTemperature();
+    float getTemperature();
     
     /* Returns the value of the humidity captured by the sensor
      * - PRE: The method read() has been performed at least once.
      */
-    int getHumidity();
+    float getHumidity();
 };
 
 #endif
\ No newline at end of file