A simple working example showing the usage of Stefan Nielsen's DHT22 library. I found this library to be much more stable than the more often used DHT.h library. My thanks also to mohamedgamal for his initial draft of this code (which is more than servicable in and of itself).

Dependencies:   DHT22 mbed

Revision:
0:214ec6f2cde1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Jul 28 20:59:39 2016 +0000
@@ -0,0 +1,19 @@
+
+#include "mbed.h"
+#include "DHT22.h"
+DHT22 dht22(PB_7);
+int main() {
+    double hum;
+    double temp;
+    
+    printf("\r\nSetting up...\r\n");
+    
+    while (1) {
+        dht22.sample() ;
+        hum=dht22.getHumidity()/10.0;
+        temp=dht22.getTemperature()/10.0;
+        printf("temperature: %3.1f, humidity: %3.1f\n\r",temp,hum);
+        wait(2);
+    }
+}
+            
\ No newline at end of file