Cod

Dependencies:   mbed DHT

Revision:
0:f2be568faec6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun May 12 01:50:01 2019 +0000
@@ -0,0 +1,32 @@
+#include "mbed.h"
+#include "DHT.h"
+ 
+DigitalOut myled(LED1);
+ 
+DHT sensor(PA_0,DHT22); // Use the SENdht22 sensor
+
+Serial PC(USBTX, USBRX);//Serial LOG
+ 
+int main() {
+    int err;
+    PC.printf("\r\nDHT Test program");
+    PC.printf("\r\n******************\r\n");
+    wait(1); // wait 1 second for device stable status
+    while (1) {
+        myled = 1;
+        err = sensor.readData();
+        if (err == 0) {
+            PC.printf("Temperature is %4.2f C \r\n",sensor.ReadTemperature(CELCIUS));
+            //PC.printf("Temperature is %4.2f F \r\n",sensor.ReadTemperature(FARENHEIT));
+            //PC.printf("Temperature is %4.2f K \r\n",sensor.ReadTemperature(KELVIN));
+            PC.printf("Humidity is %4.2f \r\n",sensor.ReadHumidity());
+            //PC.printf("Dew point is %4.2f  \r\n",sensor.CalcdewPoint(sensor.ReadTemperature(CELCIUS), sensor.ReadHumidity()));
+            //PC.printf("Dew point (fast) is %4.2f  \r\n",sensor.CalcdewPointFast(sensor.ReadTemperature(CELCIUS), sensor.ReadHumidity()));
+        } 
+       // else
+        //    PC.printf("\r\nErr %i \n",err);
+        myled = 0;
+        wait(1);
+    }
+
+}
\ No newline at end of file